When doing dynamic loading, one step is to convert jar into DEX, using the DX tool. Before, it was normal for the project to generate jar package on eclipse and convert it to DX. However, recently, the project was migrated to Android studio and the jar generated reported bad class file magic (cafebabe) or Version (0033.0000) error in converting DX
After a search on the Internet, the reason is that the JDK version of the jar package is different from that of the DX JDK. The solution is also given to reduce the java file version
javac -source 1.6 -target 1.6 xx.Java
But it doesn’t apply to me, because I have hundreds of java files that need to be reduced, and the JDK version on Android studio is the latest 1.8. Therefore, it is speculated that there will be a solution starting from the JDK used by DX. My DX tool was downloaded from the Internet. Before, I only knew how to use it. I didn’t know what was in it. The zip package only contained dx.bat and dex.jar. There is a sentence in dx.bat:
set jarfile=dx.jar
Moreover, the following command is to call DX. Jar. Since only JDK1.8 is installed on the computer, the Java version obtained through the environment variable must also be this. The only possibility is that DX. Jar is too old. Find the latest version of DX replacement in build tools in the SDK directory, test it, normal
And then we found the same solution on stack overflow
Similar Posts:
- Android AAPT2 error: check logs for details [How to Solve]
- Spring Boot Start Error: Exception in thread “main” java.lang.StringIndexOutOfBoundsException: …
- Android studio change project name exception solution: can’t rename root module
- Android ERROR: This version of Android Studio cannot open this project, please retry with Android Studio 3.6 or newer.
- ‘tools.jar’seems to be not in Studio classpath Please ensure JAVA_HOME points to JDK rather than…
- Android studio running and configuration [no module]
- Error: Can’t find bundle for base name messages.AndroidJpsBundle, locale en_US
- AndroidStudio Error:Failed to resolve: com.android.support:appcompat-v7:29
- [Solved] Android Studio uses constraintlayout preview to prompt rendering sandbox error
- How to Solve Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!