Search code examples
androidbundlejavadexjdk6

Dexifying a jar file compiled by JDK 6 gives "bad class file magic" error


I am tryig to dexify a jar file using the following command:

dx --dex --output=classes.dex JAR_file.jar

This gives me the following errors:

    trouble processing:
    bad class file magic (cafebabe) or version (0033.0000)
    .....................etc

When I searched, I found that they are the same errors that appear in this question

Yes, I was compiling my project with JDK 1.7. So I downloaded JDK 1.6, and changed the setting of my eclipse to make it use JDK 1.6.

I did that by: Window->Preferences->Compiler and then I set the compiler compilance level to 1.6. Finally, I configured the compiler to make it use JRE6 that I downloaded. I clicked OK. I tried to run my project again, and generated the jar file.

When I run the command again for dexifying that jar file. It still shows the same errors. What am I missing?

Note: The jar file is a bundle that I created in my eclipse as a "Plugin" project. Here is a snapshot of the project:

enter image description here

In the question I am referring to, the accepted answer says if you still have the same problem, then you have to make sure that every single class is compiled right. What does that mean? I tried to compile again and again, but I am still getting the same errors.


Solution

  • I created a totally new project (after changing my eclipse compiler to JDK 1.6). Then, the dexifying worked OK.