警告:Jack工具链已被弃用,Android Studio。

3

我将我的Android Studio更新到了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

警告提示添加这两行。我不需要添加这两行吗?android.compileOptions.sourceCompatibility 1.8 android.compileOptions.targetCompatibility 1.8 - Khemraj Sharma
1个回答

11

步骤 1:打开您的build.gradle文件(模块应用程序)

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

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

第三步:同步项目或者点击立即同步(出现在右上角)

注意:如果您的build.gradle(模块)中有jackOptions选项

defaultConfig {
    jackOptions {
        enabled true
    }
}

然后 移除 jackOptions 块


您还可以通过选择进行操作

文件 -> 项目结构

选择 app -> 属性,并将兼容性设置为 Java 8,如下所示:

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接