How can I solve this problem of getting execution failure?

Execution failed for task ‘:app:compileDebugJavaWithJavac’.

java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x16b68a6a) 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 @0x16b68a6a

Hei, have you solved this issue?

Take a look at:

TL;DR: you are probably using an old gradle version with a new JDK.