Can any Android library project be converted to an external JAR?
Not right now.
If not, what are the restrictions or limitations?
If your library is purely Java code, with no resources, you can create a JAR out of the .class
files, just as you would with regular Java.
If your library uses resources, you can still create a JAR as above. However, you will need to look up the R
values (e.g., R.layout.main
) via reflection or getIdentifier()
, and your resources will not be packaged in the JAR but would have to be distributed separately.
In the future, the build tools should support creating distributable JAR files out of library projects, complete with resources. The current build tools do create JARs, but they are not designed to be distributed but are rather internal build artifacts at the moment.
getIdentifier()
are distributed separately? – Spallation