引入第三方jar包的时候。遇到下面这种报错:
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.
说明jar包是在1.7环境下编译的,而Android studio 编译环境是1.8 ,这时候需要在gradle做以下配置:
1,在defaultConfig加上这样的配置:
jackOptions
{
enabled true
}
2,加上系统提示 的配置:
allprojects {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
OK,这样即可编译。