2011-11-03 37 views
1

在我在Eclipse的Android机应用我得到以下错误:转换为Dalvik格式失败,错误1在Android 4中?

[2011-11-03 19:39:12 - MiniPauker 1.0] Dx 
trouble processing "java/crcis/pauker/AddCardActivity$1.class": 

Ill-advised or mistaken usage of a core class (java.* or javax.*) 
when not building a core library. 

This is often due to inadvertently including a core library file 
in your application's project, when using an IDE (such as 
Eclipse). If you are sure you're not intentionally defining a 
core class, then this is the most likely explanation of what's 
going on. 

However, you might actually be trying to define a class in a core 
namespace, the source of which you may have taken, for example, 
from a non-Android virtual machine project. This will most 
assuredly not work. At a minimum, it jeopardizes the 
compatibility of your app with future versions of the platform. 
It is also often of questionable legality. 

If you really intend to build a core library -- which is only 
appropriate as part of creating a full virtual machine 
distribution, as opposed to compiling an application -- then use 
the "--core-library" option to suppress this error message. 

If you go ahead and use "--core-library" but are in fact 
building an application, then be forewarned that your application 
will still fail to build or run, at some point. Please be 
prepared for angry customers who find, for example, that your 
application ceases to function once they upgrade their operating 
system. You will be to blame for this problem. 

If you are legitimately using some code that happens to be in a 
core package, then the easiest safe alternative you have is to 
repackage that code. That is, move the classes in question into 
your own package namespace. This means that they will never be in 
conflict with core system classes. JarJar is a tool that may help 
you in this endeavor. If you find that you cannot do this, then 
that is an indication that the path you are on will ultimately 
lead to pain, suffering, grief, and lamentation. 

[2011-11-03 19:39:12 - MiniPauker 1.0] Dx 1 error; aborting 
[2011-11-03 19:39:12 - MiniPauker 1.0] Conversion to Dalvik format failed with error 1 

该错误只运行我的项目时,会出现。我长时间搜索正确的解决方案,但所有可能的解决方案都不起作用。顺便说一下,我使用的是Android 4.0和Eclipse 3.6,现在的项目是

这个项目在Android 2.1中工作,但在Android 4.0中没有!

回答

8

您的软件包名称以java为开头,它保留用于核心Java软件包。如果可能,您应该重命名您的软件包。

+0

感谢布里格姆,其真正的;-D –

+0

才是值得注意到,如果它的javax开始,同样的事情发生 –

3

我得到这个,因为我手动添加android.jar到构建库,因为它说它没有找到android库。此修复程序是...

  1. 删除的android.jar从建库

  2. 右键单击该项目,选择“Android的工具”,然后选择“修复项目属性”

希望这会有所帮助。

+0

谢谢,但我不知道删除构建库中的android.jar。 当我选择“修复项目属性”时,不要发生任何事情! –

+0

如果你右键点击你的项目,然后进入“Java Build Path”,然后选择“Libraries”选项卡,应该包含Android库(不仅仅是“android.jar”)我犯了手动添加“android”的错误。瓶子“,并导致了这个问题。这个视图应该包括Android/Google API库(其中包括罐子)。希望这可以帮助。 –

+0

在这种情况下,可能是您不止一次包含库/ jar,不一定是android.jar,而是另一个。我会检查以确保首先不是这种情况。 –

0

您必须检查您的项目(或依赖库)是否在构建路径(项目>属性> Java构建路径>订单和导出)中不包含android.jar

如果你的主要项目包含的android.jarAndroid的私家藏书,那么你必须检查构建路径为其添加到您的项目,并从构建路径中删除的android.jar所有库。

0

修改jar包的scope属性导致的错误,从compile-> provided,这个操作可以在File-> Project Structure-> Dependencies中修改,或者在build.gradle文件中的项目视图app文件夹中修改那里的依赖关系,相应的jar包编译修改 这样的: enter image description here

相关问题