Android--Error:Library projects cannot enable Jack. Jack is enabled in default config

来源:互联网 发布:淘宝店铺公告栏代码 编辑:程序博客网 时间:2024/06/05 17:11

在项目中使用了Java8Jack编译器来使用一些Java 8的新特性,比如Lambda。

appbuild.gradle文件中加入如下配置:

android {    compileSdkVersion 'android-25'    buildToolsVersion '25.0.2'    defaultConfig {        jackOptions {            enabled true        }    }    compileOptions {        sourceCompatibility JavaVersion.VERSION_1_8        targetCompatibility JavaVersion.VERSION_1_8    }

将项目中一些可以复用的代码整理成module,然后在app中引用。问题来了,首先是Jack是不能在modlueenable的。如果将下面代码写在modluebuild.gradle中,报错:Library projects cannot enable Jack. Jack is enabled in default config


解决办法:删除以下代码:

jackOptions {            enabled true        }

添加以下代码:

gradle.projectsEvaluated {    tasks.withType(JavaCompile) {        options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"    }}

重新编译就OK了。

阅读全文
1 0