当前的 JDK 1.8 版有一个错误,该错误会阻止 Room 进行增量操作 [英] Current JDK version 1.8 has a bug that prevents Room from being incremental

查看:346
本文介绍了当前的 JDK 1.8 版有一个错误,该错误会阻止 Room 进行增量操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试缩短多模块 Android 应用的构建时间,并且已经达到了尝试启用增量 KAPT 注释处理编译的程度.

We're trying to improve the build times of our multi-module Android app and we've reached the point where we tried to enable incremental KAPT annotation processing compilation.

  • Android Studio 版本: v3.5.2
  • 房间版本:v2.2.1
  • Gradle 版本: v5.4.6
  • Android Gradle 插件版本: v3.5.2
  • Kotlin 版本: v1.3.50
  • Android Studio version: v3.5.2
  • Room version: v2.2.1
  • Gradle version: v5.4.6
  • Android Gradle Plugin version: v3.5.2
  • Kotlin version: v1.3.50

gradle.properties:

org.gradle.daemon=true
org.gradle.caching=true
org.gradle.parallel=true

kapt.incremental.apt=true
kapt.use.worker.api=true
kapt.include.compile.classpath=false

android.databinding.incremental=true

build.gradle(在每个使用 Room 的模块中):

kapt {
    arguments {
        arg("room.incremental", "true")
    }
}

然而,在尝试使用 gradlew assemble -scan 命令对构建时间进行基准测试时,Gradle 抛出以下错误:

However, while trying to benchmark the build times using gradlew assemble -scan command, Gradle throws the following error:

warning: Current JDK version 1.8.0_201-b09 has a bug (https://bugs.openjdk.java.net/browse/JDK-8007720) that prevents Room from being incremental. Consider using JDK 11+ or the embedded JDK shipped with Android Studio 3.5+.
ANTLR Tool version 4.5.3 used for code generation does not match the current runtime version 4.7.1
[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.room.RoomProcessor (DYNAMIC).

我已经尝试在项目结构"窗口中将 Open JDK 11 设置为项目的默认 JDK,但它没有用,它抱怨它不是 JDK 8.知道这个设置有什么问题吗?

I've tried to set Open JDK 11 as the default JDK for the project in the Project Structure window, but it didn't work, it complained about it not being JDK 8. Any ideas what's wrong with this setup?

推荐答案

您将需要使用嵌入 AS 的 JDK 来解决此问题.确保使用上面的 AS 3.5.关于项目结构 -> SDK 位置确保 jdk 指向 AS 附带的 jdk./应用程序/Android Studio.app/Contents/jre/jdk/Contents/Home然后你需要重启你的 AS.

you will need to using JDK embedded with AS to solve this. make sure to use AS 3.5 above. On project structure -> SDK location make sure jdk is pointed to jdk shipped with AS. /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home Then you will need to restart your AS.

如果您从终端运行,请确保 $JAVA_HOME 包含正确的路径.

If you running from terminal make sure $JAVA_HOME contains correct path.

我猜 Android Studio 还不支持 JDK 11.我还尝试使用最新的 JDK 8(231,其中 AS 3.5 使用 202)但它导致了这个问题.

I guess Android studio not supporting JDK 11 yet. I also tried to use latest JDK 8 (231, which AS 3.5 using 202) but it causing this issue.

这篇关于当前的 JDK 1.8 版有一个错误,该错误会阻止 Room 进行增量操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆