错误"找不到属性' rectLayout'"

时间:2014-09-30 20:54:45

标签: java android wear-os

我试图在eclipse中为android佩戴创建一个新项目,但是在主要布局中存在一个问题我现在不知道如何解决它,这是我的主要布局:

<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的副本。

4 个答案:

答案 0 :(得分:5)

您发布的代码很好。这里的问题是您的classes.jar文件夹中有/libs的副本,但这不是正确使用 wearable-support-lib 的正确方法。此 wearable-support-lib 包含一些无法打包在.jar文件中的资源,因此您需要将其作为“图书馆项目”导入并附加就像其他外部库一样,它可以用于您的项目。

您需要返回与您的sdk文件夹相关的wearable-1.0.0.aar文件:
./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

  1. 将整个wearable-1.0.0.aar文件解压缩到您的工作区。你会发现它看起来几乎像一个标准的android项目。
  2. classes.jar移至/libs/classes.jar - 在此项目内,而不是您自己的项目。
  3. 现在您必须从这些文件创建新项目,其中包名称已定义为android.support.wearable
  4. 使用API​​ 20进行编译,并在 Android 标签中的项目属性中选中“Is Library”。
  5. 从项目中添加对此库项目的引用。
  6. 您可以在other answerthis great blog post(由BenjaminCabé)中查看有关使用 wearable-support-lib 的更多详细信息。

答案 1 :(得分:1)

我刚刚在模块的build.gradle的依赖项部分添加了以下代码: compile 'com.google.android.support:wearable:2.0.3' compile 'com.google.android.gms:play-services-wearable:11.0.0'

答案 2 :(得分:0)

我有时也遇到这个问题,在我的情况下,我通过右键点击AppCompat地图然后点击刷新来解决它,也可以使用你的项目文件夹。

答案 3 :(得分:0)

对我有用的是更改此设置:     xmlns:app =“ http://schemas.android.com/apk/res-auto”

收件人:     xmlns:app =“ http://schemas.android.com/apk/com.mydomain.myapp”

其中com.mydomain.myapp是我的应用程序的程序包ID。

大概是由于某些原因,res-auto功能在我的项目中无法正常工作。

相关问题