简体   繁体   English

转换为Dalvik格式失败,并在Android 4中出现错误1?

[英]Conversion to Dalvik format failed with error 1 in Android 4?

In my Android appliction in eclipse I get the following error: 在我的Eclipse Android应用中,出现以下错误:

[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

this error only appears when run my project. 仅在运行我的项目时出现此错误。 I search long time to the right solution but all possible solutions don't work. 我一直在寻找正确的解决方案,但是所有可能的解决方案都无法正常工作。 I use android 4.0 and Eclipse 3.6,now 我现在使用android 4.0和Eclipse 3.6

by the way, this project worked in Android 2.1 but in Android 4.0 No!!! 顺便说一句,该项目在Android 2.1中有效,但在Android 4.0中有效!

Your package name starts with java, which is reserved for core Java packages. 您的软件包名称以java开头,这是为核心Java软件包保留的。 You should rename your package if at all possible. 您应该尽可能重命名软件包。

I was getting this because I had manually added android.jar to the build libraries because it was saying it wasn't finding the android libraries. 我得到这个是因为我已经手动将android.jar添加到构建库中,因为这是在说找不到android库。 The fix was to... 解决方法是...

  1. Remove android.jar from the build libraries 从构建库中删除android.jar

  2. Right click on the project, go to "Android Tools", and select "Fix Project Properties" 右键单击该项目,转到“ Android工具”,然后选择“修复项目属性”

Hope this helps. 希望这可以帮助。

You have to check that your project (or dependencies libraries) doesn't contain android.jar in build path (Project>Properties>Java Build Path>Order and Export). 您必须检查您的项目(或依赖项库)在构建路径(Project> Properties> Java Build Path> Order and Export)中是否不包含android.jar

If your main project contains android.jar in Android Private Libraries then you have to check build path for all libraries which were added to your project and remove android.jar from build path. 如果您的主项目在Android私有库中包含android.jar ,那么您必须检查所有添加到项目中的库的构建路径,并从构建路径中删除android.jar

修改jar包的scope属性引起的错误,从compile->提供,此操作可以在File-> Project Structure-> Dependencies或build.gradle文件中存在依赖项的project view app文件夹中进行修改,相应的jar软件包的编译方式如下: 在此处输入图片描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM