Android的库项目不编译它(Java项目)依赖到它的罐子 [英] Android library project does not compile its (java project) dependencies into its jar

查看:131
本文介绍了Android的库项目不编译它(Java项目)依赖到它的罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的 安卓libary项目 的 - MonitoringModel - 这取决于 常规Java项目 的 - 助手(依赖于Java构建路径>项目设置助手项目中的顺序和导出选项卡中选中了 MonitoringModel )。 MonitoringModel 产生一个罐子,我下降到一个servlet项目描述的libs文件夹这里。一切正常,直到的在servlet 的需要从助手项目的方法:

I have an android libary project - MonitoringModel - which depends on a regular java project - Helpers (the dependency was set in the java build path > Projects. The Helpers project was ticked in the "order and export" tab of the MonitoringModel). MonitoringModel produces a jar which I drop to the libs folder of a servlet project as described here. All was fine till the servlet needed a method from the Helpers project :

Caused by: java.lang.NoClassDefFoundError: gr/uoa/di/java/helpers/Utils
 at gr.uoa.di.monitoring.model.Battery$BatteryFields$1.parse(Battery.java:59)
 at gr.uoa.di.monitoring.model.Battery$BatteryFields$1.parse(Battery.java:1)
 at gr.uoa.di.monitoring.model.Battery.parse(Battery.java:117)
 ... 24 more
Caused by: java.lang.ClassNotFoundException: gr.uoa.di.java.helpers.Utils
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)

结果
后来我意识到,导出的罐子(从 MonitoringModel )早已不是助手包。在助手项目不产生任何罐子所以我试图把它的斌/ 文件夹作为<一个href=\"http://stackoverflow.com/questions/661110/how-do-i-include-class-files-in-my-project-in-eclipse-java\">Add类文件夹)


I realized then that the exported jar (from the MonitoringModel) had not the Helpers packages. The Helpers project does not create any jar so I tried adding its bin/ folder as Add Class Folder)

结果


添加它也是订单和出口选项卡:

adding it also in "order and export" tab :

但仍然没有喜悦。

所以,我应该怎么设置呢?

So how should I set this up ?

回顾:什么我是后一种方式的添加一个普通的Java项目到一个Android库项目的和有这个编制的在android罐子库项目的莫名其妙。 Τhe问题是没有这么多的(Java)的类不会导出 - 作为使用这些Java类的方法不是的编译的罐子里的正确的。因此,他们被称为当上述异常。在电池$ BatteryFields $ 1.parse 方法<一个href=\"https://github.com/Utumno/MonitoringModel/blob/master/src/gr/uoa/di/monitoring/model/Battery.java#L56\"相对=nofollow>这里。

RECAP : What I am after is a way to add a regular java project into an android library project and have this compiled in the jar of the android library project somehow. Τhe problem is not so much that the (java) classes are not exported - as that the methods that use those java classes are not compiled in the jar correctly. So when they are called the exception above is thrown. The Battery$BatteryFields$1.parse method is here.

注意:直接添加助手项目的servlet的项目并不prevent例外。该异常被抛出,因为当 MonitoringModel.parse()通话 Helpers.listToString()后者是无处可寻的在monitoringmodel.jar 的结果
就目前而言,我不得不只需添加(请参见复制粘贴)助手应用于 MonitoringModel

NB : adding the Helpers project directly to the servlets project does not prevent the exception. The exception is thrown because when MonitoringModel.parse() calls Helpers.listToString() the latter is nowhere to be found in monitoringmodel.jar
For the moment I had to simply add (see Copy Paste) the Helpers packages to the MonitoringModel.

推荐答案

您必须编译你的助手的Java项目的独立,并导出一个JAR像一个普通的Java JAR

然后,你必须添加这个JAR监视的Andr​​oid库libs文件夹。

Then, you have to add this JAR to Monitor Android Library LIBS folder.

现在您可以将显示器的Andr​​oid库添加到另一个项目(从Android电子图书馆盒),这将有你需要的资源。

Now you can add the Monitor Android Library to another project (From Android Libraries box), and it will have the sources that you need.

问题是,项目选项卡不编译了,因为有些ADT版本引用的项目,所以它是没有用的。

The problem is that the Project Tab does not compile anymore the referenced project since some ADT Version, so it's useless.

这篇关于Android的库项目不编译它(Java项目)依赖到它的罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆