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

简介: 版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/78457875 在项目中使用了Java8和Jack编译器来使用一些Java 8的新特性,比如Lambda。
版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/78457875

在项目中使用了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 是不能在 modlue enable 的。如果将下面代码写在 modlue build.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了。

目录
相关文章
|
6月前
|
存储 Java 数据库
Android数据存储:什么是Room Persistence Library?
Android数据存储:什么是Room Persistence Library?
117 0
|
Android开发
IDEA编译gradle提示This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2020.3.1 or newer.
IDEA编译gradle提示This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2020.3.1 or newer.
886 1
|
3月前
|
开发工具 Android开发
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
164 4
解决Android运行出现NDK at /Library/Android/sdk/ndk-bundle did not have a source.properties file
|
3月前
|
Android开发
Cannot create android app from an archive...containing both DEX and Java-bytecode content
Cannot create android app from an archive...containing both DEX and Java-bytecode content
35 2
|
Android开发 开发者 UED
Android Design Support Library初探-更新中
Android Design Support Library初探-更新中
98 0
|
数据可视化 开发工具 Android开发
Android Git 拉取代码报错:error: cannot pull with rebase: Your index contains uncommitted changes.
造成原因:在使用Android Studio中Git的Commit Directory 将本地更改的代码保存到本地后,点击commit,发现提交不上去,发现本地有代码,这时候拉取代码,报错:cannot pull with rebase: Your index contains uncommitted changes.表示我的索引有未提交的改变
|
JSON Java Android开发
android studio中出现Cannot resolve symbol 'json'问题完整简单解决方案
android studio中出现Cannot resolve symbol 'json'问题完整简单解决方案
598 0
android studio中出现Cannot resolve symbol 'json'问题完整简单解决方案
|
开发工具 Android开发
Android Support Design Library之FloatingActionButton(二)
Android Support Design Library之FloatingActionButton(二)
77 0
Android Support Design Library之FloatingActionButton(二)
|
Android开发
Android Support Design Library之FloatingActionButton(一)
Android Support Design Library之FloatingActionButton(一)
83 0
Android Support Design Library之FloatingActionButton(一)
|
数据安全/隐私保护 Android开发 容器
Android Support Design Library之TextInputLayout(二)
Android Support Design Library之TextInputLayout(二)
138 0
Android Support Design Library之TextInputLayout(二)