NikkoNikkoNii
NikkoNikkoNii

Reputation: 169

Issue with Java on Flutter for Mac

Error Message:

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

I just installed the JDK, and this is what happens when I try to run on the Android side.

Can someone explain to me what this is and how to fix it?

Everything is the latest versions.

Upvotes: 9

Views: 9644

Answers (3)

Shima K
Shima K

Reputation: 146

I had the same error, I fixed the error, by upgrading my gradle to gradle:7.0.0 just going to (android/gradle.build) and under dependencies updating the first classpath :

classpath 'com.android.tools.build:gradle:7.0.0'

and then going to (android/gradle/wrapper/gradle-wrapper.properties) and updating gradle wrapper to /gradle-7.0.2-all.zip in distributionUrl

distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-all.zip

Upvotes: 0

It helped me to install Java 11 series (there is a place to download it on the Internet) and specify the path to it. The previous version 18 does not have to be deleted, just change the path to 11 version in the ~./shzrc file

Upvotes: 0

Mark Parris
Mark Parris

Reputation: 194

For me, it turned out to be a java version compatibility issue with Gradle. I down graded from Java SE 16 to Java SE 11 and that fixed the issue.

Upvotes: 4

Related Questions