当前位置: 首页 > 工具软件 > magic.jar > 使用案例 >

dx.jar bad class file magic (cafebabe) or version (0034.0000)

司徒鸿文
2023-12-01

最近使用 dx.jar 回编 dex 文件时遇到了这个错误

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
	at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
	at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
	at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
	at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
	at mand.dexer.Main.processClass(Main.java:665)
	at mand.dexer.Main.processFileBytes(Main.java:634)
	at mand.dexer.Main.access$600(Main.java:78)
	at mand.dexer.Main$1.processFileBytes(Main.java:572)
	at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
	at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
	at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
	at mand.dexer.Main.processOne(Main.java:596)
	at mand.dexer.Main.processAllFiles(Main.java:498)
	at mand.dexer.Main.runMonoDex(Main.java:264)
	at mand.dexer.Main.run(Main.java:230)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:187)
	at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:786)
	at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:299)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:302)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:358)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:381)
	at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:514)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:423)
	at org.eclipse.jdt.internal.ui.util.CoreUtility$BuildJob.run(CoreUtility.java:162)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

网上搜了一圈发现原因是个别jar使用低版本编译的,需要调整JRE环境,听着还挺麻烦。其实解决方法很简单,找一个新版的 dx.jar 就成了。
复制一个较新的版本 YOUR_SDK_PATH/build-tools/26.0.3/dx.jar 替换原有的就可以了。注意,这个版本是6.0

另外记录一个JDK的下载地址,各个版本都有
https://www.oracle.com/java/technologies/oracle-java-archive-downloads.html

 类似资料:

相关阅读

相关文章

相关问答