Enes Özdemir
Enes Özdemir

Reputation: 21

Flutter Getting Error While Running: java.lang.IllegalAccessError

I am trying to install flutter to my new computer. Everything seems fine in flutter doctor but when i run my app I get an error.

Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x16545f8f) 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 @0x16545f8f

How can i fix this . Please help

Upvotes: 2

Views: 4542

Answers (1)

Faiizii Awan
Faiizii Awan

Reputation: 1710

You can run your project by opening Android module in Android studio. Go to

Tools->Flutter->Open for Editing in Android Studio

Why are you facing this error?

Gradle 6 is not fully compatible with java 16. Use Java 11 will resolve the issue. Download JDK 11 64 bit version and uninstall the current version of java.

You can check your java version by running java -version in command line interface.

Note: Java 11 is ideal at this date (10 june,2021) so far.

Upvotes: 2

Related Questions