Android库项目不会将其(java项目)依赖项编译到其jar中 [英] Android library project does not compile its (java project) dependencies into its jar

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

问题描述

我有一个 android libary项目 - MonitoringModel - 这取决于 常规java项目 - 帮助者(依赖关系在java构建路径> Projects中设置。 Helpers 项目在 MonitoringModel 的订单和导出选项卡中勾选。 MonitoringModel 产生一个jar,它将放到servlet项目的libs文件夹中,如。



注意: code>帮助者项目直接到servlet项目不会阻止例外 。抛出异常,因为当 MonitoringModel.parse()调用 Helpers.listToString()后者无处可见在monitormodel.jar中

目前我不得不只需将帮助者 添加到 MonitoringModel

您必须独立编译您的Helper Java项目,并将JAR导出为正常的Java JAR



然后,您必须将此JAR添加到监视Android Library LIBS文件夹。



现在可以添加监视器Android库到另一个项目(从Android Libraries框),它将具有您需要的源。



问题是项目选项卡不再编译参考的项目自某些ADT版本以来,所以没用。


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)


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 :

but still no joy.

So how should I set this up ?

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.

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.

解决方案

You have to compile your Helper Java Project independent, and export a JAR like a normal Java JAR

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

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

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

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

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