This one has me stumped. I'm clearly missing something, but I can't figure out what.
I have a library (not an Android library - just a regular Java library project), which in turn uses other libraries. So, the setup is:
myApi.jar
|
+-- com/myapi/ ... (.class files here).
|
+-- libs/
|
+-- lib1.jar
+-- lib2.jar
Now, when I include myApi.jar
in a project in the libs directory of an Android project, like MyAndroidProject/libs
, only the com.myapi. ...
classes are getting included in the classes.dex
file. The classes from the lib1.jar and lib2.jar are not included in classes.dex
The obvious work-around is to remove the lib1.jar and lib2.jar from the myApi.jar file; and instead place them in MyAndroidProject/libs
too. However, this means the users of myApi now have to know that there are additional JAR files to be placed on the build path. This is something I am looking to avoid.
So, is there anything special I need to do to include JAR files being used internally by a library JAR in the classes.dex
file?
However, this means the users of myApi now have to know that there are additional JAR files to be placed on the build path. This is something I am looking to avoid.
Here, Android's behavior is identical to ordinary Java's -- if myApi.jar
were in support of a Swing app, you would need to either distribute all the JARs or merge all the JARs into one. Same thing with Android. You are welcome to fold all the classes from the dependent JARs into your own, or have projects reusing your JAR also add your dependencies as their own dependencies.
Note that merging JAR contents may have technical or licensing impacts, so make sure this is something you really want to do.