Felix
Felix

Reputation: 89576

Eclipse gives "Conversion to Dalvik format failed" while ant works

I recently updated my SDK Tools and the ADT Plugin to the latest version (got Android 2.3 as well). This required a few changes in my config (mainly I added proguard.config=procfg.txt to default.properties so that I could use the built-in support for proguard), and removed the old proguard config from build.xml. Now, my problem is that Eclipse gives a pretty lengthy error (which I'll embed at the end of the question) The problem is that I did not recently add any libraries. And again, compiling using ant works as expected:

$ ant debug
Buildfile: /home/felix/workspace/XXX/build.xml
    [setup] Android SDK Tools Revision 8
    [setup] Project Target: Android 2.3
    [setup] API level: 9
    [setup] 
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] No library dependencies.
    [setup] 
    [setup] ------------------
    [setup] 
    [setup] WARNING: Attribute minSdkVersion in AndroidManifest.xml (4) is lower than the project target API level (9)
    [setup] 
    [setup] Importing rules file: tools/ant/main_rules.xml

-debug-obfuscation-check:

-set-debug-mode:

-compile-tested-if-test:

-dirs:
     [echo] Creating output directories if needed...

-pre-build:

-resource-src:
     [echo] Generating R.java / Manifest.java from the resources...

-aidl:
     [echo] Compiling aidl files into Java classes...

-pre-compile:

compile:
    [javac] /opt/android-sdk/tools/ant/main_rules.xml:361: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 1 source file to /home/felix/workspace/XXX/bin/classes

-post-compile:

-obfuscate:

-dex:
     [echo] Converting compiled files and external libraries into /home/felix/workspace/XXX/bin/classes.dex...

-package-resources:
     [echo] Packaging resources
     [aapt] Creating full resource package...

-package-debug-sign:
[apkbuilder] Creating XXX-debug-unaligned.apk and signing it with a debug key...

debug:
     [echo] Running zip align on final apk...
     [echo] Debug Package: /home/felix/workspace/XXX/bin/XXX-debug.apk

BUILD SUCCESSFUL
Total time: 6 seconds

However, Eclipse is whining about repeated classes or something:

[2010-12-08 15:06:43 - XXX]: Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/android/vending/licensing/AESObfuscator;
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processClass(Main.java:338)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:315)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:266)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processOne(Main.java:284)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:220)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.run(Main.java:176)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2010-12-08 15:06:43 - XXX]: Dx at java.lang.reflect.Method.invoke(Method.java:597)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
[2010-12-08 15:06:43 - XXX]: Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/android/vending/licensing/AESObfuscator;
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processClass(Main.java:338)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:315)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.access$100(Main.java:56)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:266)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:190)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:122)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processOne(Main.java:284)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:220)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.dx.command.dexer.Main.run(Main.java:176)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[2010-12-08 15:06:43 - XXX]: Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[2010-12-08 15:06:43 - XXX]: Dx at java.lang.reflect.Method.invoke(Method.java:597)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(Unknown Source)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
[2010-12-08 15:06:43 - XXX]: Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
[2010-12-08 15:06:43 - XXX]: Dx
trouble processing:
[2010-12-08 15:06:44 - XXX]: Dxclass name (com/android/vending/licensing/LicenseCheckerCallback) does not match path (classes/com/android/vending/licensing/LicenseCheckerCallback.class)
...while parsing classes/com/android/vending/licensing/LicenseCheckerCallback.class
...while processing classes/com/android/vending/licensing/LicenseCheckerCallback.class
[2010-12-08 15:06:44 - XXX]: Dx
trouble processing:
[2010-12-08 15:06:44 - XXX]: Dxclass name (com/android/vending/licensing/NullDeviceLimiter) does not match path (classes/com/android/vending/licensing/NullDeviceLimiter.class)
...while parsing classes/com/android/vending/licensing/NullDeviceLimiter.class
...while processing classes/com/android/vending/licensing/NullDeviceLimiter.class
[2010-12-08 15:06:44 - XXX]: Dx
trouble processing:
[2010-12-08 15:06:44 - XXX]: Dxclass name (com/android/vending/licensing/PreferenceObfuscator) does not match path (classes/com/android/vending/licensing/PreferenceObfuscator.class)
...while parsing classes/com/android/vending/licensing/PreferenceObfuscator.class
...while processing classes/com/android/vending/licensing/PreferenceObfuscator.class
[2010-12-08 15:06:44 - XXX]: Dx
... --------------------------------------- ...
... and so on for every class in my project ...
... --------------------------------------- ...
[2010-12-08 15:06:44 - XXX]: Dx229 warnings
[2010-12-08 15:06:44 - XXX]: Dx2 errors; aborting
[2010-12-08 15:06:44 - XXX] Conversion to Dalvik format failed with error 1

Why is this happening? Why is it looking in classes/, which doesn't exist?

The project worked without any problems until yesterday, and it still works if compiled via ant.


Edit: The usual Fix project properties and Clean project don't work.


Edit 2: The errors keep coming and going. I do not have any .jars. Also, I'm using ProGuard. At some point ant stopped working as well (can't remember the errors), I did a

touch `find .`

and things started working again (both Eclipse and ant), for a while. Now Eclipse spews errors again. What's going on!?


Edit 3: It would seem the problem lies with the ProGuard integration. Whenever I comment out the proguard.config directive from default.properties and to a project refresh + clean, it works. This is pretty weird because, when building in debug mode, Eclipse shouldn't obfuscate / optimize the code via ProGuard anyway. Also, my ProGuard configuration works just fine via Ant.


Edit 4: Eclipse + Ant + ProGuard = not getting along together. If I close Eclipse, uncomment my proguard.config directive, build with Ant, comment my proguard.config directive, open Eclipse, Eclipse starts spewing errors. It would seem like Ant is leaving something behind. If I do a clean project it works just fine.

Upvotes: 4

Views: 9310

Answers (8)

Solutions to errors conversion of dalvik failure format and error sun / misc / basecoder64 in Eclipse.

Instructions to solve the problem are:

  1. Install Windows XP sp2 with Java 6 or Ubuntu.

  2. Download adt version 23.0.2 with SDK 19.

  3. Decompress the adt and install it on your computer.

  4. Open the Eclipse as administrator and import the android file.

  5. In the file project.properties write this -> target = android-19 <-- very important.

  6. Export your project and this error will no more appear.

Upvotes: -1

aasha
aasha

Reputation: 436

This happens when there are multiple instances of the same library is included in the build path.

Upvotes: 0

Sveinung Kval Bakken
Sveinung Kval Bakken

Reputation: 3824

Just a little FYI, we ran into this same issue due to a jar stuck in our /libs/ folder. Everything built fine in Eclipse, but our build slave complained about duplicate class definitions. We had the same classes as plain .java's, the .jar in our /libs/ was not included in the build path, but seems like the ant build script on our Jenkins build server included it anyhow. Deleted it from /libs/ and everything is back to normal now :)

Upvotes: 0

Peterdk
Peterdk

Reputation: 16015

I had same problems.

My working solution:
1 ant clean, to get rid of dex errors
2 add .jars in libs to eclipse project (aadt errors?)

I have no problems when using proguard in settings.

Upvotes: 1

JulianHarty
JulianHarty

Reputation: 3286

FYI I managed to get the same error message when building one of my applications using ant. however in my case I'd left 2 versions of a jar file in the libs folder. Both jar files were included by my modified ant script (based on recommendations from Can't build and run an android test project created using "ant create test-project" when tested project has jars in libs directory ) which caused the issue. My eclipse project only had one of the 2 libraries specified so didn't encounter the problem.

My solution was simple and worked, I renamed one of the 2 jar files to another extension .jazz and I was able to build the project successfully using ant.

Upvotes: 0

AppsBeyond
AppsBeyond

Reputation: 49

Execute "ant clean" then clean your project in Eclipse. Make sure you save your proguard generated files (/bin/proguard) before doing this because the "bin" and "gen" dirs get deleted. Annoying solution, but that is how I got around this issue.

Upvotes: 5

Felix
Felix

Reputation: 89576

It seems the problem was with Eclipse and Ant not getting along together. I've stopped using Ant at all and now Eclipse seems to be working fine (I can even export signed & obfuscated packages using the wizard).

So, to conclude, Ant + Eclipse = a big no no.

Upvotes: 4

Octavian Helm
Octavian Helm

Reputation: 39604

Make sure to update to the latest ADT version which is 8.0.1 as of a few hours ago.

Upvotes: 2

Related Questions