9

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.

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! Any ideas what might have caused this?
Can you actually explain how you downgraded Java on Android Studio?
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

Comments

0

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

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.