Pages Navigation Menu

Coding is much easier than you think

Conversion to dalvik format failed with error 1 : Android Error

Conversion to dalvik format failed with error 1 : Android Error

 

java.lang.IllegalArgumentException: already added: package/MyClassclass; [2011-01-19 14:54:05 – …]: Dx1 error; aborting [2011-01-19 14:54:05 – …] Conversion to Dalvik format failed with error 1

 

Go to Project» Properties» Java Build Path» Libraries and remove all except the “Android X.Y” (in my case Android 1.5). click OK. Go to Project» Clean» Clean projects selected below» select your project and click OK. That should work.

It is also possible that you have a JAR file located somewhere in your project folders (I had copied the Admob JAR file into my src folder) and THEN added it as a Java Path Library. It does not show up under the Package Explorer, so you don’t notice it, but it does get counted twice, causing the dreaded Dalvik error 1.
 
** UPDATE: Android Complete tutorial now available here.
 
Another possible reason could be package name conflicts. Suppose you have a package com.abc.xyz and a class named A.java inside this package, and another library project (which is added to the dependency of this project) which contains the same com.abc.xyz.A.java, then you will be getting the exact same error. This means, you have multiple references to the same file A.java and can’t properly build it.


Windows 7 Solution:

Confirmed the problem is caused by ProGuard command line in the file,

[Android SDK Installation Directory]toolsproguardbinproguard.bat

Edit the following line will solve the problem:

call %java_exe% -jar "%PROGUARD_HOME%"libproguard.jar %*

to

call %java_exe% -jar "%PROGUARD_HOME%"libproguard.jar %1 %2 %3 %4 %5 %6 %7 %8 %9


Here’s another scenario, and solution:

If you run into this problem recently after updating the ADT for Eclipse:

In your app project, check for any linked source folders pointing to your library projects (they have names in the form “LibraryName_src”).

Select all those projects, right-click, choose “Build Path”->”Remove from Build Path”. Choose “Also unlink the folder from the project”, and click “Yes”. Clean, rebuild and redeploy the project.

It seems the reason is that some previous version of ADT linked Library project source folders to the “child” projects, and the current ADT/Dex combination isn’t compatible with that solution anymore.

 

About Gokul


I am very much interested in android and Wicket framework. A core android developer and working in android native app development and responsive web mobile design. I have also worked in wicket fame work and java web development. I will keep on updating you about android and wicket framework and answer your query.