android - 找不到以下类 : - android. support.wearable.view.WatchViewStub

标签 android android-studio adt wear-os

尝试使用 Android Wear 时,我在 Android Studio 上的项目中遇到此错误:

The following classes could not be found:

- android.support.wearable.view.WatchViewStub (Fix Build Path, Create Class)

导致这些错误的原因:

Error:(2) No resource identifier found for attribute 'rectLayout' in package...

Error:(2) No resource identifier found for attribute 'roundLayout' in package...

我该如何解决这个问题?谢谢!

最佳答案

当您使用 Android Studio 项目向导创建可穿戴应用时,会自动包含一个非官方的 UI 库。您还可以使用以下依赖声明将库添加到您的 build.gradle 文件中:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.support:wearable:+'
    compile 'com.google.android.gms:play-services-wearable:+'
}

我在 build 文件夹下创建了一个 build.gradle 文件,添加了这些依赖行,一切都很好。

http://developer.android.com/training/wearables/apps/layouts.html#UiLibrary

关于android - 找不到以下类 : - android. support.wearable.view.WatchViewStub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24560441/

相关文章:

android - Nexus 9 模拟器未在 AVD 中显示

android - 如何在EditText中输入彩色文本

java - Android Studio/Gradle - 从公共(public)代码构建两个应用程序

android - 如何在后台生成我的缩略图?

android - 克隆现有的 Android Studio 项目

java - Android Studio 预览版 : This JVM does not support constant tag 15

java - 使用 Eclipse 的 Android 项目给出错误 : Cannot switch on a value of type String for source level below 1. 7

android - 安装ADT插件错误

android - 无法在 Android 的简单适配器中设置评级栏

android - 如何在recyclerview中显示所有复选框?