简体   繁体   English

Android(Java)中另一个jar内的jar

[英]A jar inside another jar in Android (Java)

I have a library project that uses a jar ("httpmime-4.1.3.jar"). 我有一个使用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. 我想获取该项目生成的jar并在其他项目中使用它,但是当我在其他项目中使用它时,需要一个“httpmime-4.1.3.jar”类,应用程序崩溃时会出现NoClassDefFoundError。

How can I solve that without having to add the "httpmime-4.1.3.jar" to all the projects reusing the library? 我如何解决这个问题而不必在所有重复使用该库的项目中添加“ httpmime-4.1.3.jar”? Thanks! 谢谢!

You might consider using something like maven for dependency management. 您可以考虑使用maven之类的东西进行依赖关系管理。 With maven, you specify the libraries that your library project depends on (httpmime). 使用maven,您可以指定库项目所依赖的库(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. 然后,任何依赖于您的库的项目都会自动识别它需要下载并将httpmime jar放在其类路径中,您不必担心手动复制文件。

Edit: I just saw that you're specifically looking at android development. 编辑:我刚看到你专门研究android开发。 Here is a plugin with a nice getting started guide for using maven with android. 这是一个插件,有一个很好的入门指南 ,使用maven与android。

You have to add it to the classpath. 您必须将它添加到类路径中。 You can't include it in another jar. 你不能把它包含在另一个罐子里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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