javafluttergradlewgradle-wrapper

Build failed exception while running flutter in MacOs


flutter run Launching lib/main.dart on V2060 in debug mode...

FAILURE: Build failed with an exception.

Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @686d592a

BUILD FAILED in 23s Running Gradle task 'assembleDebug'... 25.2s Exception: Gradle task assembleDebug failed with exit code 1

This error I'm facing.

How to solve this in MacOs.


Solution

  • I had same error in one of my project. Turned out, that after updating some libraries and build toolchain (gradle, etc), build started to demand newer Java version. I updated JDK from 8 to 11 at that time and it helped.

    But it is 2024 now :) I think, that you should maybe update JDK to 17 or even newer. Here is useful link for that:

    1. Gradle compatibility matrix – helps determine appropriate version for Gradle itself.
    2. Unfortunately, there is no equivalent link for Android Grade Plugin, so you should check release notes of your version. In release notes, they usually put compatibility matrix for JDK, Gradle and other tools. Example link for Android Gradle Plugin 8.3.0 (you can change numbers in it for your release): https://developer.android.com/build/releases/past-releases/agp-8-3-0-release-notes

    So, this is a little puzzle :) Wish you luck in solving it.