【问题标题】:Compiling simple wearable app in Android Studio - WatchActivity not found在 Android Studio 中编译简单的可穿戴应用程序 - 未找到 WatchActivity
【发布时间】:2014-07-10 04:08:31
【问题描述】:

我按照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,但我有相同的结果 - 由于这些无法识别的类,程序将无法编译。任何输入表示赞赏!谢谢

【问题讨论】:

    标签: android android-studio wear-os


    【解决方案1】:

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

    Android Wear 活动的基类就是标准的Activity

    (另外,如果您使用的是 Android Studio 0.8.0,请更新到 0.8.1 -- 0.8.0 的模板中有一个错误,并使用extend WatchActivity 创建新的活动,这实际上是无效的)。

    【讨论】:

    • 谢谢,这个解决方案解决了我遇到的问题。不幸的是,我有一个新问题,详细的here,如果你想检查一下。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多