解决eclipse sdk中build-tools想用新版本但是报错的问题(ysdk更新示例)

最近应用宝ysdk更新到1.5.9了,没有了eclipse的接入方式,只能自己解压arr接了。但是导入ysdk的jar包后打包时会报错,报错如下

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 com.android.dx.command.dexer.Main.processClass(Main.java:665)
	at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
	at com.android.dx.command.dexer.Main.access$600(Main.java:78)
	at com.android.dx.command.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 com.android.dx.command.dexer.Main.processOne(Main.java:596)
	at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
	at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
	at com.android.dx.command.dexer.Main.run(Main.java:230)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:188)
	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:726)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
	at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
	at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
	at org.eclipse.core.internal.resources.Project.build(Project.java:124)
	at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
	at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855)
	at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704)
	at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047)
	at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
...while parsing android/os/ZygoteStartFailedEx.class

[2020-03-25 11:01:36 - JiangHu] Dx 1 error; aborting
[2020-03-25 11:01:36 - JiangHu] Conversion to Dalvik format failed with error 1

搜了一下,是说dx.jar或者jdk版本和编译jar包的版本对不上,然后就去查看ysdk.jar包里的编译版本,查看位置是jar包里的META-INF->MANIFEST.MF

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.2
Created-By: 1.8.0_91-b14 (Oracle Corporation)

1.9.2是sdk的build-tools版本,1.8.0_91是jdk版本。

我寻思我电脑上jdk只有1.8的啊,那只能是dx.jar的问题了,然后去下载了1.9.2版本的build-tools,但是eclipse打包的时候又报如下错

[2020-03-25 11:00:44 - Dex Loader] Failed to load D:\adt-bundle-windows-x86_64-20140702\sdk\build-tools\android-10\lib\dx.jar
[2020-03-25 11:00:44 - JiangHu] Unknown error: Unable to build: the file dx.jar was not loaded from the SDK folder!

其实这个错只会在eclipse上打包会报,用ant直接打包是没问题的。

这不行啊,我得在eclipse上调试啊。

我吐了,找了好久最后终于在stackflow上找到了解决方案,需要把之前版本内的dx.jar下的com.android.dx.command.DxConsole.class 复制到新版本的dx.jar包下即可(可以用winrar同时打开新旧版本的dx.jar,然后把DxConsole用鼠标拖过去)。

新版本的 YSDk 还使用到了 androix 的一些 supprt 依赖: androidx.core.content.FileProvider 和 androidx.localbroadcastmanager.content.LocalBroadcastManager。需要引入androidx的jar包,可以去github这位老哥那边下载,链接:https://github.com/dandar3,需要引入androidx.core.jar和 androidx.localbroadcastmanager.jar

希望能帮到其他人,垃圾ysdk,呕

发布了4 篇原创文章 · 获赞 2 · 访问量 2532
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 书香水墨 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览