13

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.

Spencer
  • 2,245
  • 3
  • 28
  • 50
  • Visit here for same question discussion it may help u http://stackoverflow.com/questions/2680827/conversion-to-dalvik-format-failed-with-error-1-on-external-jar?rq=1 – manish Apr 11 '13 at 04:57
  • what helps me in this situation is: delete all content of "bin" folder, clean project, run app on test-device, build signed release apk again. – dy_ Jan 18 '14 at 01:54

3 Answers3

27

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.

Spencer
  • 2,245
  • 3
  • 28
  • 50
12

Go to project and unselect Build Automatically. Then Clean the project and Build all. Worked for me to export signed application package

anjaneya
  • 708
  • 9
  • 11
2

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.

Ted8119
  • 33
  • 5
  • I have tried every suggested solution but this is the only one that worked for me. – Beshoy Fayez Mar 17 '15 at 00:39
  • But isn't this bad? I mean suppose I want to publish my app. Won't the deoptimized version be worse than the optimized version? This problem happened to me after I made some code changes, so I'm wondering if ProGuard is confusing some new symbols I've introduced... –  Feb 01 '17 at 09:26