Search code examples
javaandroidwear-os

Error "No resource identifier found for attribute 'rectLayout'"


I was trying to create a new project for android wear in eclipse , but there is a problem in main layout i don't now how i can solve it , this is my main layout:

<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>

it is give me this error :

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'

my project have two layouts "rect.xml" and "round.xml" and it is compile with 4.4W and target is 4.4W and also i have a copy of classes.jar in libs folder .


Solution

  • The code you've posted is fine. The problem here is that you have a copy of classes.jar in your /libs folder, but this is not a right way to properly use wearable-support-lib. This wearable-support-lib contains some resources that cannot be packaged inside a .jar file, so you need to import it as a "Library project" and attach it to your project just like other external libraries.

    You need to go back to the wearable-1.0.0.aar file, located in relation to your sdk folder:
    ./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

    1. Unzip the whole wearable-1.0.0.aar file somwehere to your workspace. You will see that it looks almost like a standard android project.
    2. Move classes.jar to /libs/classes.jar - inside this project, not to your own project.
    3. Now you have to create new project from these files, with package name defined android.support.wearable.
    4. Compile it with API 20 and check "Is Library" in project properties in Android tab.
    5. Add reference to this library project from your project.

    You can see more details about using wearable-support-lib in my other answer and in this great blog post (by Benjamin Cabé).