问题描述
自从我将 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 时出错:
原因:Dex 无法解析版本 52 字节代码.这是由使用 Java 8 或更高版本编译的库依赖项.如果您在库子模块中使用java"gradle 插件添加targetCompatibility = '1.7' sourceCompatibility = '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
文件中
这篇关于Android Studio 2.1 将字节码转换为 dex 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!