您的位置:首页 > 编程语言 > Java开发

Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes

2016-02-25 16:40 501 查看
直播:

项目代码让同事加入了一个Java libary 工程各种修改*****拷到本机报错

Error:Error converting bytecode to dex:

Cause: java.lang.RuntimeException: Exception parsing classes

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_20\bin\java.exe'' finished with non-zero exit value 1


找了半天也没发现哪有问题。。。

通过排除法缩小范围找到是因为这个java libary的问题,做了一个测试

在AS中添加一个Java libary 工程 引用后编辑报错

com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)


困扰我半天的问题。

最后发现同事的jre是1.7我是1.8后才知道

解决办法:

1.JavaHome 改成1.7

2.Java Libary工程中

apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7


In the experimental version of Gradle the syntax is:

compileOptions.with
{ sourceCompatibility=JavaVersion.VERSION_1_7 targetCompatibility=JavaVersion.VERSION_1_7 }


Android 工程中

compileOptions{
sourceCompatibility=JavaVersion.VERSION_1_7
targetCompatibility=JavaVersion.VERSION_1_7
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: