粘贴了一个jar包后,报错:
image.png
image.png
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.
第一步
在项目的build.gradle(注意不是工程的文件夹下)文件夹下添加如下代码,就可以轻松解决问题:
1、在defaultConfig {}中添加
jackOptions{
enabled = true
}
2、在android {}添加
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
新的报错
经过第一步的处理,出现了新的报错
image.png
几番尝试未果, 在张兄帮助下,观察和原版代码的配置区别
注意主要区别在于buildToolsVersion的不同,
原版是26.0.1
我的是28.0.3:
image.png
于是尝试改成26.0.1,sync now, 报错说没有这个工具,点下载,再次sync ,再build,成功
至此,问题解决