1

I have a problem to run flutter app from VS Code,

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 @0x3d67da21) 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 @0x3d67da21

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 3s
Exception: Gradle task assembleDebug failed with exit code 1

What flutter doctor said :

[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-arm, locale
    en-RS)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio
    ✗ **Unable to find bundled Java version.**
[✓] Connected device (2 available)
Milos N.
  • 4,416
  • 6
  • 18
  • 31

2 Answers2

4

I resolved it on my side by creating a symbolic link:

cd /Applications/Android\ Studio.app/Contents/jre;
ln -s ../jre jdk;
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk

Not the most elegant solution, but worked. the problem is that the system finds two java versions, and either the android licenses are not accepted, or the bundled version is not found. So instead I removed the link and added an other one. and that finally did the trick

source: https://github.com/flutter/flutter/issues/27136#issuecomment-888915746

Display name
  • 753
  • 10
  • 28
  • 1
    I'm almost try all possible solution but nothing work. Only this one work for me. Its from `August 9, 2021` Check the link for the solution https://stackoverflow.com/a/68703869/8555332 – Tahmid Bin Rashid Aug 08 '21 at 20:12
  • 1
    Agree with you @TahmidBinRashid. I tried all solutions, but only this one give me smile. It's from `Sept 25, 2021` – Bali Codes Sep 25 '21 at 05:03
  • On my case: The folder /Library/Internet Plug-Ins/ is empty! what's can I do? – Hicham Jan 15 '23 at 10:31
0

I think you should specify the path to your Java SDK in Android Studio, you can set it by doing the following:

Generally speaking, it is set in the "Project Structure" dialog.

Go to File > Project Structure > SDK Location. The third field is "JDK Location" where you can set it. This will set it for the current project.

How to set Java SDK path in AndroidStudio?

Ronan
  • 61
  • 3