标签:
将xstream1.4.8 引入Android Strudio项目中,编译报错如下:
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 com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
...while parsing com/thoughtworks/xstream/mapper/LambdaMapper.class
1 error; aborting
Error:Execution failed for task ‘:app:preDexDebug‘.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/opt/jdk/jdk1.7.0_71/bin/java‘‘ finished with non-zero exit value 1
Information:BUILD FAILED
究其原因,xstream1.4.8为Java8编译,而目前AS尚只支持Java7。那么我们只好使用低版本的xstream。
大家可以尝试去这里下载,但那个狠心的家伙要6分。不过里面的例子和jar包都很全,积分少的可以联系我。
http://download.csdn.net/download/xiaokui_wingfly/8800295
既然可以解析json和xml,那么这个库应该能够吃得开才对。目前很多项目既要解析xml,又要解析json。如果一个库搞定,学习成本会下降很多。
Android问题集锦之四十九:Can't add XStream file dependency to Android Studio project
标签:
原文地址:http://blog.csdn.net/lincyang/article/details/51638422