错误“找不到属性'rectLayout'的资源标识符'
我正在尝试为eclipse中的android磨损创建一个新项目,但主布局中存在一个问题我现在不怎么解决这个问题,这是我主要布局:错误“找不到属性'rectLayout'的资源标识符'
<android.support.wearable.view.WatchViewStub
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/watch_view_stub"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="@layout/rect"
app:roundLayout="@layout/round"
tools:context=".MyActivity"
tools:deviceIds="wear">
</android.support.wearable.view.WatchViewStub>
它给我这个错误:
Multiple annotations found at this line:
- error: No resource identifier found for attribute 'rectLayout' in package
'com.example.wear'
- error: No resource identifier found for attribute 'roundLayout' in package
'com.example.wear'
我的项目有两个布局“rect.xml”和“round.xml”,它是编译4.4W和目标是4.4W,我也有libs文件夹中的classes.jar的副本。
您发布的代码很好。这里的问题是您的/libs
文件夹中有classes.jar
副本,但这不是正确使用穿戴支持库文件的正确方法。这穿戴支持库包含一些无法打包在.jar
文件中的资源,因此您需要将其导入为“库项目”,并将其作为其他外部库附加到您的项目。
你需要回到wearable-1.0.0.aar
文件,位于相对于您的SDK文件夹:./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar
- 解压整个
wearable-1.0.0.aar
文件somwehere到您的工作空间。你会看到它看起来几乎像一个标准的Android项目。 - 移动
classes.jar
至/libs/classes.jar
- 在此项目中,而不是您自己的项目。 - 现在您必须从这些文件中创建新项目,其中包名定义为
android.support.wearable
。 - 使用API 20编译它,并在Android选项卡中选中项目属性中的“Is Library”。
- 从您的项目中添加对此库项目的引用。
你可以看到有关我的other answer和this great blog post使用可佩戴支持-lib的(本杰明CABE)的更多细节。
谢谢,它正在工作:) – 2014-09-30 23:22:19
我也有时会遇到这个问题,在我的情况下,我通过在AppCompat地图上点击右键,然后点击刷新来解决它,然后使用您的项目文件夹执行此操作。
我只是说在依赖部分下面的代码在我的模块build.gradle
: compile 'com.google.android.support:wearable:2.0.3' compile 'com.google.android.gms:play-services-wearable:11.0.0'
我不认为有一个名为rectLayout为'http://schemas.android.com/apk属性/ res-auto' – zgc7009 2014-09-30 21:03:31