[英]Android: Getting Error: Conversion to Dalvik format failed
I am building an app on android and running into an error and while searching on net, came across your posting on this and changed the eclipse.ini to increase Xms and Xmx params but still this error does not go away. 我在android上构建应用程序并遇到错误,并且在网上搜索时,碰到了您在此发布的内容,并更改了eclipse.ini以增加Xms和Xmx参数,但此错误仍然存在。
I am using Eclipse IDE for Java with Android SDK 2.1 on Mac OS. 我在Mac OS上将Eclipse IDE for Java与Android SDK 2.1一起使用。 Please help or please point me to someone who might know.
请帮助或将我指向可能认识的人。
Btw, this error only happens when i add external jar files (which i need for my project). 顺便说一句,此错误仅在我添加外部jar文件(我的项目需要)时发生。 Here are the list of external jar files that i have in my classpath.)
这是我在类路径中拥有的外部jar文件的列表。)
Here is the complete error: 这是完整的错误:
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/impl/AvalonLogger;
[2010-05-02 21:57:05 - MyApp] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main.processClass(Main.java:301)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main.processFileBytes(Main.java:278)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:229)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.cf <http://com.android.dx.cf.direct.ClassPathOpener.pro> .direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main.processOne(Main.java:247)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
[2010-05-02 21:57:05 - MyApp] at com.android.dx.command.dexer.Main.run(Main.java:139)
[2010-05-02 21:57:05 - MyApp] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2010-05-02 21:57:05 - MyApp] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2010-05-02 21:57:05 - MyApp] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2010-05-02 21:57:05 - MyApp] at java.lang.reflect.Method.invoke(Method.java:592)
[2010-05-02 21:57:05 - MyApp] at com.android.ide.eclipse.adt.internal.sdk.DexWrapper.run(Unknown Source)
[2010-05-02 21:57:05 - MyApp] at com.android.ide.eclipse.adt.internal.build.ApkBuilder.executeDx(Unknown Source)
[2010-05-02 21:57:05 - MyApp] at com.android.ide.eclipse.adt.internal.build.ApkBuilder.build(Unknown Source)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
[2010-05-02 21:57:05 - MyApp] at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
[2010-05-02 21:57:05 - MyApp] 4 errors; aborting
[2010-05-02 21:57:05 - MyApp] Conversion to Dalvik format failed with error 1
In r14 they changed the way in which external libraries are referenced and it can cause this problem. 在r14中,他们更改了引用外部库的方式,这可能会导致此问题。 You can fix it by removing the linked folders (with _src in the name) from the folder tree:
您可以通过从文件夹树中删除链接的文件夹(名称中带有_src)来解决此问题:
see http://android-developers.blogspot.co.uk/2011/10/changes-to-library-projects-in-android.html 参见http://android-developers.blogspot.co.uk/2011/10/changes-to-library-projects-in-android.html
UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/impl/AvalonLogger;
意外的最高级别异常:java.lang.IllegalArgumentException:已添加:Lorg / apache / commons / logging / impl / AvalonLogger;
You are attempting to add org.apache.commons.logging.impl.AvalonLogger
twice to your project. 您试图将
org.apache.commons.logging.impl.AvalonLogger
两次添加到您的项目中。 Do not do that. 不要那样做。
Also, much of what you are adding via JARs is already in Android, such as HttpClient. 另外,通过JAR添加的大部分内容已经在Android中,例如HttpClient。 This may be contributing to your error.
这可能是造成您的错误的原因。
I just had this as well but I made sure ahead of time that I did not have a duplicate class in my jar file. 我也有这个,但是我事先确定我的jar文件中没有重复的类。 This was some other issue dealing with multiple loading of the same jar or something.
这是处理同一罐子或其他东西的多次装载的其他问题。 The classpath and the list of Referenced Libraries looked appropriate.
类路径和引用库列表看起来很合适。 After some flailing around, some combination of the following fixed it:
经过一番摸索之后,下面的一些组合将其修复:
Some combination of the above seemed to fix the issue. 上面的某种组合似乎可以解决此问题。 If it happens again, I will be more careful to see if I can reproduce it.
如果再次发生,我会更加小心,看看是否可以重现。
i guess that you put your jar in folder for example library and then, build path from this folder. 我猜您将jar放在例如库的文件夹中,然后从该文件夹构建路径。 You just remove this jar file and try select property from project, then Java build path -> Add external jars files.
您只需删除此jar文件,然后尝试从项目中选择属性 ,然后选择Java构建路径 -> 添加外部jar文件。 It will works fine.
它将正常工作。
I had this problem because I put the .jar under my src/
directory, so Eclipse copied it to the bin/
directory and tried to link it from both places. 我遇到了这个问题,因为我将.jar放在
src/
目录下,因此Eclipse将其复制到bin/
目录,并尝试从两个位置进行链接。 Moving it from src/
to libs/
fixed the problem. 将其从
src/
移至libs/
解决此问题。
My problem was due to having the same project references also in library projects. 我的问题是由于在图书馆项目中也有相同的项目引用。 A few updates ago this was normal behaviour, but since the change in library handling, I now needed to remove the references from my projects and have only one of the libraries reference it.
之前有一些更新,这是正常的行为,但是由于更改了库处理方式,现在我需要从项目中删除引用,并且只有一个库对其进行引用。
This always happened to me after I did a custom build using a custom command using proguard. 在使用proguard使用自定义命令进行自定义构建后,这总是发生在我身上。
I solved this problem by emptying the bin directory of my eclipse project directory and then cleaning the project (Eclipse menu "project" --> "clean...") 我通过清空eclipse项目目录的bin目录然后清理项目来解决此问题(Eclipse菜单“ project”->“ clean ...”)
Obviously proguard makes a mess in this directory by which Eclipse gets confused... 显然,proguard在该目录中弄得一团糟,使Eclipse感到困惑。
I get really mad with this problem trying to do all the posible solutions, but none worked for me: Clean project, Re-build, erasing libraries, linking again the libraries, updating proguard, editing proguard files... 我对尝试执行所有可能的解决方案感到非常恼火,但没有一个对我有用:清理项目,重新生成,擦除库,再次链接库,更新proguard,编辑proguard文件...
Finally the solution was much more easy: Project , Android Tools , Fix project propieties . 最终,解决方案变得更加简单: Project , Android Tools , Fix project propiesies 。
Now I can export the apk. 现在,我可以导出apk了。
Right click the src and gen folders and select Build Path > Remove from Build Path. 右键单击src和gen文件夹,然后选择“构建路径”>“从构建路径中删除”。 then Right Click > Build Path > Use as Source Folder
然后右键单击>构建路径>用作源文件夹
当我尝试在不兼容的android版本中运行代码时,我会时不时地得到该信息(例如,当特定库正常工作需要4.0时为2.2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.