警告:Jack工具链已弃用Android工作室

时间:2017-11-07 05:31:56

标签: java android java-8 android-gradle build.gradle

我将我的android工作室更新到版本3.0,我在以前版本的工作室中使用jackOption。更新后出现此警告。我收到了这个警告。但我不知道在哪里添加这两行建议?

Warning:The Jack toolchain is deprecated and will not run. To enable support for Java 8 language features built into the plugin, remove 'jackOptions { ... }' from your build.gradle file, and add

    android.compileOptions.sourceCompatibility 1.8
    android.compileOptions.targetCompatibility 1.8

Future versions of the plugin will not support usage of 'jackOptions' in build.gradle.
To learn more, go to https://d.android.com/r/tools/java-8-support-message.html

1 个答案:

答案 0 :(得分:11)

步骤1:打开build.gradle(模块应用)

步骤2:在android块下添加以下行

android {
    //.. other code
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

第3步:同步项目或点击sync now(显示在右上角)

注意:如果jackOptions(模块)中有build.gradle

defaultConfig {
    jackOptions {
        enabled true
    }
}

然后删除jackOptions Block

您也可以通过选择

来完成

File -> Project structure

选择app->Properties并选择java 8作为兼容性

enter image description here