Issue with Java on Flutter for Mac

7,254

Solution 1

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

Solution 2

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.

Share:
7,254
NikkoNikkoNii
Author by

NikkoNikkoNii

Aspiring to be a self-taught app developer.

Updated on December 28, 2022

Comments

  • NikkoNikkoNii
    NikkoNikkoNii 10 months

    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.