相关疑难解决方法(0)

Android:Dex无法解析版本52字节的代码

我刚刚切换到Android Studio 2.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.
Run Code Online (Sandbox Code Playgroud)

我已经更新了主项目的gradle.build文件以强制生成Java 1.7代码:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        apply plugin: 'java'
        sourceCompatibility = 1.7
        targetCompatibility = 1.7
    }
}
Run Code Online (Sandbox Code Playgroud)

我还更新了gradle.build模块,如下所示设置java版本:

android …
Run Code Online (Sandbox Code Playgroud)

java android maven android-studio

93
推荐指数
7
解决办法
8万
查看次数

标签 统计

android ×1

android-studio ×1

java ×1

maven ×1