Reputation: 2245
I know a form of this question is out there, but I can't find anything specifically that fits my scenario, so here it is.
My app compiles and runs perfectly when testing in the emulator, but when I try to export a signed apk I get the Conversion to Dalvik format failed with error 1
. The Eclipse error log shows this stack trace:
com.android.ide.eclipse.adt.internal.build.DexException: Conversion to Dalvik format failed with error 1
at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:751)
at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:269)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:296)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:233)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:218)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
I don't have the naming collisions that other people seem to have (at least it doesn't say so in the error), and I'm stumped as to why it runs in the emulator, but I can't export.
I'm not using ProGuard either, by the way.
Upvotes: 13
Views: 7565
Reputation: 33
After a lot of attempts I managed to find out the reason why this issue occurs. In general, this is caused by ProGuard and specifically its optimization. At least in my case I had 4 corrupt projects with this error, but after I disabled the ProGuard optimization, all of them were built correctly. So, in your ProGuard config comment the -optimizations and -optimizationpasses options and add -dontoptimize
# -optimizations ...
# -optimizationpasses 5
-dontoptimize
Hope this helps.
Upvotes: 2
Reputation: 2245
It looks like ADT 21 adds a folder to your bin called dexedLibs which ought to speed up deployment by putting jars and libraries in precompiled dex code. I had two versions of the support library there, so I deleted all the files in the folder and built again and it worked. If I try to build with any files in there the build fails though, so I have to delete them before each export. I'm using ActionBar Sherlock and that may be conflicting with the dexedLibs thing because it won't show up there unless the folder is initially empty.
Edit: I had been using ActionBarSherlock when this problem first came up, but have recently switched to ActionBarCompat. Since the switch, I no longer have to delete the dexedLibs folder when exporting. Looks like maybe ActionBarSherlock was to blame, but I can't be certain.
Upvotes: 27
Reputation: 708
Go to project and unselect Build Automatically. Then Clean the project and Build all. Worked for me to export signed application package
Upvotes: 12