I followed the instructions here on how to create an Android library project, and use it in an Android application:
http://developer.android.com/guide/developing/eclipse-adt.html
but it is not working. I can see the library project is added to my application but I cannot reference anything in it because it won't build. The R.java file from the lib is NOT being added to my application project, so the lib project contains tons of errors, everywhere it tries to reference it's own R.java file.
I don't know if this has anything to do with it, but in the console there are messages stating that the there is "No resource identifier found for attribute 'X' in package 'Lib Package'. My library package has a a few styleable attributes defined for a custom view I made, all of which are being complained about in this console message. The library builds just fine, and I don't get those messages in the console until I hook the library to my application, so I don't know what's up with this.
I really would like to get this working. I've spent two entire days on it, to no avail. Please offer any ideas you might have to help!
The answer to my conundrum was that the library had an attrs.xml file that defined a few custom attributes for a custom view I created. I removed attrs.xml and hardcoded the values in the custom view code, rebuilt the library, and problem solved.
This isn't cool though, what this means is that custom views with custom attributes can't be used in libraries. I hope Google fixes this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With