Addev
Addev

Reputation: 32233

A jar inside another jar in Android (Java)

I have a library project that uses a jar ("httpmime-4.1.3.jar"). I'd like to take the jar generated by that project and use it in other projects but when I use it in other projects and one class of the "httpmime-4.1.3.jar" is required the app crashes with a NoClassDefFoundError.

How can I solve that without having to add the "httpmime-4.1.3.jar" to all the projects reusing the library? Thanks!

Upvotes: 1

Views: 563

Answers (2)

wpgreenway
wpgreenway

Reputation: 1719

You might consider using something like maven for dependency management. With maven, you specify the libraries that your library project depends on (httpmime). Then, any project that depends on your library will automatically recognize that it needs to download and put the httpmime jar in its classpath as well, and you don't have to worry about manually copying files around.

Edit: I just saw that you're specifically looking at android development. Here is a plugin with a nice getting started guide for using maven with android.

Upvotes: 2

Bozho
Bozho

Reputation: 597114

You have to add it to the classpath. You can't include it in another jar.

Upvotes: 1

Related Questions