R.java file from an Android library project not importing an application into the project

I followed the instructions here on how to create an Android library project and use it in an Android app:

http://developer.android.com/guide/developing/eclipse-adt.html

but it does not work. I see that the library project has been added to my application, but I can’t reference anything because it will not be created. The R.java file from lib is NOT added to my application project, so the lib project contains many errors, everywhere it tries to link to its own R.java file.

I don’t know if this is related to this, but there are messages on the console that say “there is no resource identifier found for the attribute“ X ”in the package“ Lib Package. ”Aa several custom attributes defined for the user view, which I did, all of which complain about this console message.The library builds just fine, and I do not receive these messages in the console until I connect the library to my application, so I don’t know what it is.

I really would like this to work. I spent the whole two days to no avail. Please suggest any ideas that may help you!

+7
android reference
source share
2 answers

The answer to my riddle was that the library had an attrs.xml file that defined several custom attributes for the custom view I created. I removed attrs.xml and hardcoded the values ​​in the user view code, restored the library, and fixed the problem.

This is not great, but it does mean that custom views with custom attributes cannot be used in libraries. I hope Google fix it.

+14
source share

Actually this is a duplicate file issue. You cannot create a project containing more than one instance of the same file. Due to the nature of the project file in an Android project, as a rule, the first is to deny a successful build.

0
source share

All Articles