Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dx bad class file magic (cafebabe) or version (0033.0000) with ADK14

Tags:

java

android

Since moving to ADK14, I have been unable to build new apks for release on my Windows 7 system.

Building fails with "conversion to dalvik format failed with error 1", while the console is filled with lots of "Dx bad class file magic (cafebabe) or version (0033.0000)".

The full exception text:

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:740)
at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:204)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:290)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:229)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:214)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

I am building an old project that uses lots of libraries, so presumably the problem is related to this fact. Already done all the "Fix Properties"/Clean etc that are suggested when moving to ADK14 (as I naturally had all those problems), but they haven't helped with this.

All the libraries are on the same Android SDK and JDK/JRE version, so this wouldn't seem to be the issue.And in fact, the app is easily built in debug and installed on my old version 1.5 HTC Magic - it is only when I need to export a signed application package that this breaks down.

[Edit] This is on a Windows 7x64 PC. I observe that packing the apk on my Linux laptop (Lucid Lynx) for the exact same code has absolutely no problems whatsoever.

Any ideas? Getting very frustrated with this.

NOTE

Apparently, this error message can be triggered by a variety of different problems. My particular problem was not related to Java 6/7, as I never installed Java 7 in the first place, and compiler compliance was set to Java 6 (I checked at the time, as I had seen that solution suggested elsewhere).

like image 656
Michael A. Avatar asked Oct 23 '11 14:10

Michael A.


2 Answers

Compiling with Java 6 instead of 7 worked for me, but only after I configured Eclipse to "know about" my JRE6 install path. Previously I only had the JRE7 set up in Eclipse. I could set my compiler compliance level to 1.6 or 1.5 but apparently without the corresponding JRE it didn't really have any effect. I don't really understand why that should be--what does the JRE have to do with compiling, and what does it have to do with Android code?

like image 51
John Avatar answered Oct 18 '22 11:10

John


I found the solution to this problem at last.

If you look in Proguard.bat (Android SDK\tools\proguard\bin), you will find the following line:

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

Replace it with the following:

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

It's a stupid old issue, that I actually realize that I have seen before, now that I have figured it out. Apparently the Android SDK team still haven't fixed this problem, and it was reintroduced when I did a clean install of the Android SDK.

like image 27
Michael A. Avatar answered Oct 18 '22 12:10

Michael A.