今天真的头痛,在导入第三方库的时候(就是Github上面的识别生成二维码功能的库)
https://github.com/bertsir/zBarLibary
导入
compile ‘cn.bertsir.zbarLibary:zbarlibary:1.4.1’
报了个错:
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的gradle里添加这两个语句,谷歌百度轮流搜索一番,发现问题的解决方法比较重,与题意对不上,好多地方是建议改成1.8再使用,不是很理解这一块。
我的做法是添加:
dexOptions {
preDexLibraries false
jumboMode true
javaMaxHeapSize "2g"
incremental false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
添加之后build.gradle里面配置如下:
因为我依赖的第三方是在java8编译的,但是我工具的只是java1.7,所以才出现这个问题