引用外部类 [英] Referencing external classes
问题描述
我的Android项目引用未在Android SDK中包括在外部类文件。我在eclipse中添加这些类作为外部库正常。在code没有问题的编译。但是,当我尝试运行应用程序,我得到了一个DalvikVM ClassNotFoundException的,尽管所有的neccessary类已经被移植。
My Android project references external classfiles that are not included in the in the Android SDK. I added those classes as an external library properly in eclipse. The code compiles with no problem. But as I try to run the application I get an ClassNotFoundException by the DalvikVM, although all the neccessary classes have been ported.
我缺少的东西吗?
我做的步骤。
- 在Eclipse中创建Android项目新的文件夹。
- 此文件夹中复制neccessary类。
- 通过Eclipse的文件夹添加到类路径。
- PROGRAMM
- 编译
- 运行的Android应用程序
- - >例外
编辑:
我想现在添加外部JAR。我收到以下错误,当Eclipse正在重建构建路径:
I tried to add the external jar now. I get the following errors when eclipse is rebuilding the build path:
警告:忽略InnerClasses属性为一个匿名内部类,没有附带相关的EnclosingMethod属性(这个类可能是由一个破碎的编译器产生)
"warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. (This class was probably produced by a broken compiler.)"
这涉及在罐子显然每一个类文件。
That comes for every class file in the jar apparently.
和地塞米松装载机]无法执行DEX:空
和转换为Dalvik的格式失败:无法执行DEX:空
and: "Dex Loader]Unable to execute dex: null" and: "Conversion to Dalvik format failed: Unable to execute dex: null"
推荐答案
的Android开发工具(ADT) - 我假设你正在使用它来构建你的项目 - 只回升了位于外部罐子库您的Android项目的文件夹中。否则,他们不会得到回升,并转换成Dalvik的字节code,并添加到您的classes.dex文件:
The Android Development Tools (ADT) - I assume you're using this to build your project - will only pick-up external jars that are located in the "libs" folder of your Android project. Otherwise, they won't get picked up and converted to Dalvik bytecode and added to your classes.dex file:
http://mylifewithandroid.blogspot.com/2010/01/罐子上,classpath.html
不幸的是,它不会增加你只需添加到您的Java项目构建路径的类。
Unfortunately, it won't add classes that you just add to your Java project build path.
这篇关于引用外部类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!