引用外部类 [英] Referencing external classes

查看:140
本文介绍了引用外部类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid项目引用未在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.

我缺少的东西吗?

我做的步骤。


  1. 在Eclipse中创建Android项目新的文件夹。

  2. 此文件夹中复制neccessary类。

  3. 通过Eclipse的文件夹添加到类路径。

  4. PROGRAMM

  5. 编译

  6. 运行的Andr​​oid应用程序

  7. - >例外

编辑:

我想现在添加外部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"

推荐答案

的Andr​​oid开发工具(ADT) - 我假设你正在使用它来构建你的项目 - 只回升了位于外部罐子库您的Andr​​oid项目的文件夹中。否则,他们不会得到回升,并转换成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屋!

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