I had this exact issue: wanting to distribute my library as a jar file. A reasonable number of support issues were caused by people just not being familiar with the library project bits (shocking to me, but who am I to argue).
First, there was really no support for automatically generating java classes from XML layouts. I'd thought that I could perhaps extract the source code used by the ADT to render your XML layouts into separate classes, but after futzing around with that for a couple of hours I gave up and wrote the layouts out by hand. Make them extend RelativeLayout
and build the hierarchy in code. Works, but doesn't quite scale. At some point it may be worth digging into the ADT source to allow you to export a layout.
For images I restricted it to just icons, then wrote an ugly little tool that would generate a byte[]
array from the PNG files and then adds that as a static final variable in a separate class for each image: you're limited to small images, I think less than 40k or some unknown part of the Android build process craps out because the generated class files are too large. Once that is done I can reconstitute the images in my view classes using code like this:
audio_icon = new BitmapDrawable(BitmapFactory.decodeByteArray(AudioIcon.bytes, 0, AudioIcon.bytes.length));
I have a package for all the icons, and it actually worked pretty well. You do give up the customization options offered by the library format, but it has made our integration process real simple.