Java – Error “No resource identifier found for attribute ‘rectLayout'”

Error “No resource identifier found for attribute ‘rectLayout'”… here is a solution to the problem.

Error “No resource identifier found for attribute ‘rectLayout'”

I

tried to create a new project for android wear in eclipse, but there is a problem with the main layout I don’t know how to solve it now, 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>

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 has two layouts “rect.xml” and “round.xml”, it compiles with 4.4W, the target is 4.4W, and I have a copy of classes.jar in the libs folder.

Solution

There is no problem with the code you published. The problem here is that you have a copy of classes.jar in the /libs folder, but this is not the correct use of the wearable-support-library. This wearable-support-lib contains some assets that can’t be packaged into .jar files, so you’ll need to import it as a “Library project” and attach it to your project, just like any other external library.

You need to return to the wearable-1.0.0.aar file associated with your SDK folder:
./extras/google/m2repository/com/google/android/support/wearable/1.0.0/wearable-1.0.0.aar

  1. Extract the entire wearable-1.0.0.aar file to your workspace. You will find that it looks almost like a standard Android project.
  2. Move classes.jar to /libs/classes.jar – in this project, not your own.
  3. Now you must create a new project from these files, with the package name defined as android.support.wearable.
  4. Compile it with API 20 and check “Is Library” in the project properties on the Android tab.
  5. Add a reference to the library project from your project.

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

Related Problems and Solutions