android - 在 Android Studio 中编译简单的可穿戴应用程序 - 未找到 WatchActivity

标签 android android-studio wear-os

我按照 this link 中的说明进行操作在 Android Studio 中创建一个简单的移动/可穿戴应用程序。但是,它不会识别任何特定于可穿戴 SDK 的类,并给出错误“无法解析符号 ______”。截图在this link这就是我所看到的。

以下是我的build.gradle文件:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 20
    buildToolsVersion '20.0.0'
    defaultConfig {
         applicationId 'com.example.lsykora.androidwearwidget'
         minSdkVersion 'L'
         targetSdkVersion 'L'
         versionCode 1
         versionName '1.0'
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-    rules.pro'
    }
}
productFlavors {}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// You must install or update the Support Repository through the SDK manager to use      this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:+'
compile 'com.google.android.support:wearable:+'
compile 'com.google.android.gms:play-services-wearable:+'
}

我已经使用 SDK 管理器安装了所有 SDK,并且尝试修改 build.gradle 文件中的最小、目标和编译 SDK,将它们设置为 19、20 或 Android-L,但我有相同的结果 - 由于这些无法识别的类,程序无法编译。任何输入表示赞赏!谢谢

最佳答案

不要扩展 WatchActivity(该类实际上并不存在)。

Android Wear Activity 的基类就是标准的 Activity .

(此外,如果您使用的是 Android Studio 0.8.0,请更新至 0.8.1——0.8.0 在其模板中存在错误并使用 extend WatchActivity 创建新的 Activity,这是实际上无效)。

关于android - 在 Android Studio 中编译简单的可穿戴应用程序 - 未找到 WatchActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24657160/

相关文章:

c# - Tizen.NET 调试错误无法加载文件或程序集'Samsung.Sap

android - 在android中的TextView中显示大字符串

Android:如何在不更改当前语言环境的情况下获取特定语言环境中的字符串

android - apk 的文件传输失败

android - 如何获取相机应用的包名

java - 尝试将 EditText 表单提交到我的电子邮件时出错?没有应用程序可以执行此操作?

第三方应用的Android测试记录和webview支持

android - 在其他计算机上打开项目时出现Gradle错误

android - 无法将数据推送到 android wear(模拟器)

android - WearOS 上的全屏进度条