Flutter for Mac 上的 Java 问题

Nik*_*Nii 6 java macos android android-studio flutter

错误信息:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x71871a5e) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x71871a5e

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 42s
Exception: Gradle task assembleDebug failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

我刚刚安装了 JDK,这就是我尝试在 Android 端运行时发生的情况。

有人可以向我解释这是什么以及如何解决它吗?

一切都是最新版本。

Mar*_*ris 4

对我来说,结果是 Gradle 的 java 版本兼容性问题。我从 Java SE 16 降级到 Java SE 11,这解决了这个问题。

  • 您能具体解释一下您是如何在 Android Studio 上降级 Java 的吗? (4认同)