简体   繁体   中英

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!

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM