Android: Getting Error: Conversion to Dalvik forma

2020-03-01 08:33发布

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.

I am using Eclipse IDE for Java with Android SDK 2.1 on Mac OS. 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). Here are the list of external jar files that i have in my classpath.)

  • httpclient-4.0.1.jar from apache
  • httpcore -4.0.1.jarfrom apache
  • commons-codec-1.3.jar from apache
  • commons-logging-1.1.1.jar from apache
  • json_simple-1.1.jar from google

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

标签: android
11条回答
一纸荒年 Trace。
2楼-- · 2020-03-01 08:51

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. Moving it from src/ to libs/ fixed the problem.

查看更多
祖国的老花朵
3楼-- · 2020-03-01 08:53

This always happened to me after I did a custom build using a custom command using proguard.

I solved this problem by emptying the bin directory of my eclipse project directory and then cleaning the project (Eclipse menu "project" --> "clean...")

Obviously proguard makes a mess in this directory by which Eclipse gets confused...

查看更多
Emotional °昔
4楼-- · 2020-03-01 08:55

i guess that you put your jar in folder for example library and then, build path from this folder. You just remove this jar file and try select property from project, then Java build path -> Add external jars files. It will works fine.

查看更多
欢心
5楼-- · 2020-03-01 08:55

Right click the src and gen folders and select Build Path > Remove from Build Path. then Right Click > Build Path > Use as Source Folder

查看更多
Anthone
6楼-- · 2020-03-01 08:56

UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: Lorg/apache/commons/logging/impl/AvalonLogger;

You are attempting to add org.apache.commons.logging.impl.AvalonLogger twice to your project. Do not do that.

Also, much of what you are adding via JARs is already in Android, such as HttpClient. This may be contributing to your error.

查看更多
兄弟一词,经得起流年.
7楼-- · 2020-03-01 08:58

i got that from time to time when i tried to run code in an incompatible version of android (ie 2.2 when 4.0 was needed for a particular library to work)

查看更多
登录 后发表回答