错误"找不到属性'rectLayout'的资源标识符"

Abd*_*zmy 3 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>
Run Code Online (Sandbox Code Playgroud)

它给我这个错误:

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'
Run Code Online (Sandbox Code Playgroud)

我的项目有两个布局"rect.xml"和"round.xml",它是用4.4W编译的,目标是4.4W,而且我在libs文件夹中有一个classes.jar的副本.

Mac*_*ęga 5

您发布的代码很好.这里的问题是classes.jar你的/libs文件夹中有一份副本,但这不是正确使用wearable-support-lib的正确方法.这个wearable-support-lib包含一些无法打包到.jar文件中的资源,因此您需要将其作为" 库项目 " 导入,并像其他外部库一样将其附加到项目中.

您需要返回wearable-1.0.0.aar与您的sdk文件夹相关的文件:
./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. 从项目中添加对此库项目的引用.

您可以在我的其他答案本篇博文(BenjaminCabé)中看到有关使用wearable-support-lib的更多详细信息.