码迷,mamicode.com
首页 > 移动开发 > 详细

Android问题集锦之四十九:Can't add XStream file dependency to Android Studio project

时间:2016-06-12 02:07:25      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:

将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。如果一个库搞定,学习成本会下降很多。

参考:
http://stackoverflow.com/questions/28946049/cant-add-xstream-file-dependency-to-android-studio-project/28971602

Android问题集锦之四十九:Can't add XStream file dependency to Android Studio project

标签:

原文地址:http://blog.csdn.net/lincyang/article/details/51638422

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!