问题描述
自从我将android studio从2.0更新为2.1后,我收到以下错误。
I am getting the following error since I updated the android studio from 2.0 to 2.1.
原因:Dex无法解析版本52字节的代码。这是由使用Java 8或更高版本编译的
库依赖项引起的。如果
你在库子模块中使用'java'gradle插件,则将
targetCompatibility ='1.7'ourceCompatibility ='1.7'添加到
子模块的build.gradle文件中。
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中添加以下代码段,但问题仍然存在
I tried adding the following snippet in build.gradle, but still the issue persists
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
我看到一些与此类似的问题,但两个问题都没有得到解答。任何人都可以帮我解决这个问题吗?在此先感谢。
I saw some of the questions similar to this, but neither of the questions answered. Can anyone help me to solve this? Thanks in advance.
推荐答案
尝试
allprojects {
tasks.withType(JavaCompile) {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
}
主要 build.gradle
文件中的
in the main build.gradle
file
这篇关于Android Studio 2.1将字节码转换为dex时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!