Conversion to Dalvic failed with error 1 in AndEngine project

My adventures with the marvelous AndEngine library continue. I had just completed my live wallpaper BizarreMachine III. I could not be happier after all my travails setting up AndEngine for my Android project the thing was finally finished. I set about trying to export a release build when I hit  a huge snag. I got a Conversion to Dalvic failed with error 1. I started to Google frantically and for 4 days I got different solutions non of which worked.

The first was advice asking you to search for duplicated *.jars. I had none. Then there was advice to clean the project and restart Eclipse. I did that a number of times with no success.
Next was to download the latest version of Proguard and change the default Proguard settings in my project from this

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
There was also the advice to remove the android-support-v4.jar from the libs folder sans success.
In all this what was clear was the fact that it was a library issue.

The solution was this:

  1. Go to the bin folders for AndEngine and AndEngineLiveWallpaperExtension.
  2. Take the *.jars and save them in a folder in your project.
  3. Unlink the AndEngine aand AndEngineLiveWallpaper libraries from your Project>Properties>Android Libraries tab.
  4. Clean your project and Export. 
It should work, it worked for me

Caveat: I had to make these changes when the above method resulted in a java.lang.RuntimeException: Unable to instantiate service [name of package].[name of activity] on the exported apk.
Remove existing referencing libraries (Right click project > properties, remove the libraries under "Android" tab and those in buildpath except for your Android.X.X/
Go to your project, create a folder "libs"
Then place the jars into the folder (andengine.jar and andengineextension.jar etc)
Make them into buildpath by right click on the jars u just placed.

0 comments:

My Instagram