"Conversion to Dalvik format failed with error 1" after update to ADT 14

10,743

Solution 1

This problem is listed as a known issue of ADT 14. Here's the quote from the Android Tools Project Site:

Project not building with error [2011-10-20 23:32:04 - MyApp] Dx UNEXPECTED TOP-LEVEL EXCEPTION:<class>: already added: <class> This is due to a failure to remove previous library source folders from the main project. Incidentally, the fragility around those linked source folders is one of the reason we are moving away from this mechanism (see more info at http://tools.android.com/recent/buildchangesinrevision14). The solution is to remove those <libraryname>_src source folders from your projects. Just right click them and choose Build Path > Remove from Build Path. You should also be prompted to remove the linked folder which you should do. If you're not prompted, remove it manually. You can see some screenshot of the problem in this great post: http://android.foxykeep.com/dev/fix-the-conversion-to-dalvik-format-failed-with-error-1-with-adt-14

Solution:

As it says, the solution is to remove the <libraryname>_src source folders from your projects. You can do this by right clicking them and choose "Build Path -> Remove from Build Path" or in your project properties (Java Build Path -> Source tab).

Solution 2

I also ran into this problem, but none of the above fixed it:

  • Tried removing/re-adding libraries with clean builds along the way
  • Tried deleting and re-importing projects

No dice. Still the "Conversion to Dalvik format failed with error 1" was staring me in the face every time I tried to export to an apk.

I could tell the problem was related to ProGuard, because when I commented out this line in my project.properties file, everything worked fine:

proguard.config=proguard.cfg

However, I wasn't able to solve the problem until I found this post by David M Young. Apparently, ADK/ADT 14 shipped with an incorrect version of ProGuard (oops!). I downloaded ProGuard version 4.6. Replaced the android-sdk\android-sdk\tools\proguard\lib directory contents with proguard4.6.zip\proguard4.6\lib (3 *.jar files), restarted Eclipse and export to apk worked again!

Solution 3

To solve you should:

  • Right click on your project>Properties>Java Build Path and remove all libs but the one Android I.J (depending on your version)
  • Project>Clean
  • Add back the libs you've removed

If the problem comes back another times it's useful to put the libs outside your project and import them as "External JARs"

Solution 4

Hello thought I'd throw my two cents in here. as I did do that,

"_src -> Remove from path"

Then I cleaned it and rebuilt and I could get it to run in debug mode on my phone just fine. I could also export it; but only if I disabled proguard. of course I couldn't leave it like that with my code open for all to see. so it was quite madding. but I Finally found a cure, oddly enough they had the same problem (and fix) with r12 as they do with this one.

it's in: [Android SDK Installation Directory]\tools\proguard\bin\proguard.bat

Change

call %java_exe% -jar "%PROGUARD_HOME%"\lib\proguard.jar %*

to

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

I tried tons of other stuff but this is what did it for me.

Share:
10,743
ashughes
Author by

ashughes

Updated on June 15, 2022

Comments

  • ashughes
    ashughes almost 2 years

    After updating to the latest developer tools, ADT 14, my Android project that includes library projects will no longer run producing the error:

    Dx UNEXPECTED TOP-LEVEL EXCEPTION: ... already added: ...
    ...
    Conversion to Dalvik format failed with error 1
    

    The other threads describing this issue with solutions that include removing and re-adding the projects do not work.

  • ashughes
    ashughes over 12 years
    Sorry to those of you who answered my question already. I was posting the question and solution to help others find this issue regarding ADT 14 easier (since other questions were asked prior to ADT 14 being released), but I couldn't post my answer right away because I didn't have over 100 rep. I wanted to include more info like the quote from the Android Tools Project site.
  • ashughes
    ashughes over 12 years
    Google published a blog post describing the changes to Library Projects in ADT 14: android-developers.blogspot.com/2011/10/…
  • gregdev
    gregdev over 11 years
    Thanks, I tried a bunch of different solutions but this one finally sorted it out for me.