包括其他的Eclipse项目的Andr​​oid应用程序项目项目、其他的、应用程序、Eclipse

2023-09-04 07:08:40 作者:霓裳

我有一个图书馆,只有Android的Eclipse项目(无主类,只有库中的类),我想在我的主Android应用程序的项目包括。

I have a library-only Android eclipse project (no main class, only library classes) that I want to include in my main Android Application project.

我去构建路径,增加库项目的项目选项卡上的构建路径上的必需项目,并检查它的排序和导出选项卡上。

I went to the Build Path and added the library project to the "Required projects on the build path" on the Projects tab, and checked it on the "Order and Export" tab.

然而,应用程序运行时,它发出的VerifyError例外,因为从库项目中的类并没有发生被打包在一起的APK。

However, when the application is run, it emits VerifyError exception, because the class from the library project didn't happen to be packaged together in the apk.

任何解决办法?

推荐答案

Android的项目没有得到包装,很遗憾。如果你的库项目只有类,而不是资源,那么你可以把它一个普通的Java项目。 ,一个Android项目依赖于Java项目做得到包装

Android projects don't get packaged in, unfortunately. If your library project only has classes, not resources, then you can make it a normal Java project. Java projects that an Android project depends on do get packaged in.

如果库项目采用Android特有的类,然后当你让一个Java项目,你还需要的android.jar添加到构建路径。这将是平台/ Android的1.6 /的android.jar里面如果您已经安装了1.6平台,你的SDK目录,例如。

If the library project uses Android specific classes, then when you make it a Java project you also have to add android.jar to the build path. This will be "platforms/android-1.6/android.jar" inside your SDK directory if you have the 1.6 platform installed, for example.