Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle prints a 'java.lang.System::load has been called' warning on newer JDKs

ErrorWARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module

Short answer

From JDK 24 the JVM warns when code calls System::load without native access enabled. Gradle's native-platform library does exactly that, so the warning is printed. It does not fail the build today, but the JVM says it will be blocked later. Pass --enable-native-access=ALL-UNNAMED to the JVM that prints it.

  • Applies to JDK 24, Gradle 8.x, Flutter 3.3x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check which JDK runs Gradle and which Gradle version you have. The warning needs JDK 24 or later, and the Gradle compatibility table says JDK 24 can run Gradle from 8.14 onward.

    java -version
    ./gradlew --version
  2. 2Match what you see, then jump to its fix

    1. 1The warning names net.rubygrapefruit.platform.internal.NativeLibraryLoader and appears on every Gradle startGradle's own JVM loads native-platform without native accessFix
    2. 2The warning appears in the output of one task, such as compileJava or test, not at Gradle startA forked compile or test JVM prints itFix
    3. 3You run JDK 24 or later with a Gradle version older than the compatibility table allowsGradle is too old for the JDKFix

What does the error look like?

  • WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module
  • Restricted methods will be blocked in a future release unless native access is enabled

Cause 1 of 3

Gradle's own JVM loads native-platform without native access

1Check

JDK 24 restricts System::load under JEP 472. Gradle's native-platform library calls it from an unnamed module, so the JVM prints the warning. It is a warning, not a build failure.

./gradlew --version 2>&1 | head -20

2Fix

Give the Gradle JVM the flag through the GRADLE_OPTS environment variable. Flutter's own tooling does the same for Gradle runs, because the wrapper it injects is old.

export GRADLE_OPTS="$GRADLE_OPTS --enable-native-access=ALL-UNNAMED"

3Verify

Run the build again; the warning lines are gone.

flutter build apk --debug

Confirmed by github.com

Did this fix it?

Cause 2 of 3

A forked compile or test JVM prints it

1Check

Compile and test tasks may run in their own JVM. Gradle does not add the flag to those automatically.

./gradlew build --info 2>&1 | grep -n "has been called"

2Fix

Add the flag to the task's JVM arguments in the Kotlin DSL build file.

tasks.compileJava {
    options.forkOptions.jvmArgs = listOf("--enable-native-access=ALL-UNNAMED")
}
tasks.withType<Test>().configureEach {
    jvmArgs("--enable-native-access=ALL-UNNAMED")
}

3Verify

Run that task again and search the output for the warning.

./gradlew test --info 2>&1 | grep -n "has been called"

Confirmed by github.com

Did this fix it?

Cause 3 of 3

Gradle is too old for the JDK

1Check

Each Gradle release supports a range of JDKs; JDK 24 can run Gradle from 8.14, JDK 25 from 9.1.0.

./gradlew --version

2Fix

Upgrade the wrapper to a version that supports your JDK, or run Gradle on an older supported JDK.

./gradlew wrapper --gradle-version 8.14

3Verify

The version output shows the new Gradle and the build starts.

./gradlew --version

Confirmed by docs.gradle.org

Did this fix it?

How do I stop it coming back?

  • Keep Gradle and the JDK on a combination the compatibility table lists.
  • Set GRADLE_OPTS once in your shell profile or CI environment.
  • Update Flutter and its Gradle wrapper regularly.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Flutter Android: Failed to load FirebaseOptions from resource

Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.

On Android, Firebase reads its settings from a values.xml file that the Google services Gradle plugin builds from google-services.json.

4 causes, each with a fix

Mobile apps

Flutter's Android build stops: JAVA_HOME is not set

ERROR: JAVA_HOME is set to an invalid directory

The Gradle wrapper script needs a Java runtime and looks in two places: the JAVA_HOME variable, then a java command on PATH.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.