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

尝试使用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 Project Wizard创建可穿戴应用程序时,会自动包含一个非官方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性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...