本人在idea写了几个简单地类,然后打包成jar包;拷贝android studio libs文件夹下,然后add as library;这样在本人的代码里使用类的时候完全没有问题,但是编译的时候一直报3个错:Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the “java” gradle plugin in a library submodule add
targetCompatibility = “1.7”
sourceCompatibility = “1.7”
to that submodule”s build.gradle file.
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task “:app:transformClassesWithDexForDebug”.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process “command “C:\Program Files\Java\jdk1.8.0_60\bin\java.exe”” finished with non-zero exit value 1
根据网上搜索到的方法,本人在buid.gradle里面加入了repositories {
jcenter()
}
tasks.withType(JavaCompile) {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
},完全没有用,还在报同一种错误。
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the “java” gradle plugin in a library submodule add
targetCompatibility = “1.7”
sourceCompatibility = “1.7”
to that submodule”s build.gradle file.
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task “:app:transformClassesWithDexForDebug”.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process “command “C:\Program Files\Java\jdk1.8.0_60\bin\java.exe”” finished with non-zero exit value 1
根据网上搜索到的方法,本人在buid.gradle里面加入了repositories {
jcenter()
}
tasks.withType(JavaCompile) {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
},完全没有用,还在报同一种错误。
解决方案
60
这样试试?在android里面加上:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
实在不行你直接降低java版本算了,你这个貌似不支持java8
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
实在不行你直接降低java版本算了,你这个貌似不支持java8