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.
Requirements to create Flutter projectJava 11 JDK installed and set in system environment variables. Flutter and Dart extension installed. Connected Device with laptop for run and test flutter applications.
flutter - Android Gradle plugin requires Java 11 to run.
Go to File > Project Structure. Select the SDK Location section in the list of the left. Deselect the Use embedded JDK (recommended) option. Enter the absolute path of your installed JDK in the text box.
macOS supports developing Flutter apps in iOS, Android, and the web. Complete at least one of the platform setup steps now, to be able to build and run your first Flutter app. To develop Flutter apps for iOS, you need a Mac with Xcode installed. Install the latest stable version of Xcode (using web download or the Mac App Store ).
Start Android Studio, and go through the ‘Android Studio Setup Wizard’. This installs the latest Android SDK, Android SDK Command-line Tools, and Android SDK Build-Tools, which are required by Flutter when developing for Android. Run flutter doctor to confirm that Flutter has located your installation of Android Studio.
It's more than annoying because it diverts attention from flutter doctor output, where the real solution lies. And the link to get the JDK is not only the wrong link (to the Apple Safari home page!), it leads users to think that they need to do yet another standalone install.
If you are using a Ruby Version manager, you may need to run without sudo. Open the default Xcode workspace in your project by running open ios/Runner.xcworkspace in a terminal window from your Flutter project directory. Select the device you intend to deploy to in the device drop-down menu next to the run button.
This is because your $JAVA_HOME
is not set
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home
" in .bash_profile
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With