Compiling simple wearable app in Android Studio - WatchActivity not found

人盡茶涼 提交于 2019-12-19 07:27:14

问题


I followed the instructions at this link to create a simple mobile/wearable app in Android Studio. However, it won't recognize any of the classes specific to the wearable SDK, giving the error "cannot resolve symbol ______". The screenshot at this link is what I am seeing.

The following is my build.gradle file:

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:+'
}

I have installed all SDK's using SDK manager and I have tried tinkering with the minimum, target, and compile SDK's in the build.gradle file, setting them to 19, 20, or Android-L, but I'm having the same results - program won't compile because of these unrecognized classes. Any input is appreciated! Thanks


回答1:


Don't extend WatchActivity (that class doesn't actually exist).

The base class for Android Wear activities is just the standard Activity.

(Also, if you're using Android Studio 0.8.0, update to 0.8.1 -- 0.8.0 has a bug in its templates and creates new Activities using extend WatchActivity, which is actually invalid).



来源:https://stackoverflow.com/questions/24657160/compiling-simple-wearable-app-in-android-studio-watchactivity-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!