简体   繁体   中英

Issues when referencing android library project with user defined attributes

The issue is:

  1. I have a project A. It runs well.
  2. Then I config A as a library project. And new a project B to use it.

Then the issue comes like followings: \\res\\layout\\taskslist.xml:18: error: No resource identifier found for attribute 'content' in package 'com.XXX'

The attribute named 'content' is defined in XML used by MultiDirectionSlidingDrawer in project A:

<resources>
 <declare-styleable name="MultiDirectionSlidingDrawer">
        <attr name="content" format="reference" />
        </declare-styleable>
</resources>

And the taskslist.xml looks like:

<com.XXX.util.MultiDirectionSlidingDrawer
    xmlns:my="http://schemas.android.com/apk/res/com.XXX"
    ...
    my:content="@id/content">
    <include
        android:id="@+id/content"
        layout="@layout/menuwithll" />
    <ImageView
        android:id="@+id/handle"
        ... />
</com.XXX.util.MultiDirectionSlidingDrawer>

Actually I look into R.java in project A. There is an attr named "content" likes:

public static final class attr {
     public static int content=0x7f010002;
}

Anyone know this issue? Thanks in advance!!!

BTW. I have tried clean project. And config project B both in "Android" and "Java build path".

For later one's who also has this issue. It's really simple to resolve by add following code in you layout file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:my="http://schemas.android.com/apk/res-auto"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM