android studio导入jar包总是编译出错的问题
我在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
}
},完全没有用,还在报同一种错误。