Gradle prints a 'java.lang.System::load has been called' warning on newer JDKs
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed moduleShort 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.
Fix it fast
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 --version2Match what you see, then jump to its fix
- 1
The warning names net.rubygrapefruit.platform.internal.NativeLibraryLoader and appears on every Gradle startGradle's own JVM loads native-platform without native accessFix - 2
The 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
You run JDK 24 or later with a Gradle version older than the compatibility table allowsGradle is too old for the JDKFix
- 1
What does the error look like?
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed moduleRestricted 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 -202Fix
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 --debugConfirmed by github.com
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
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 --version2Fix
Upgrade the wrapper to a version that supports your JDK, or run Gradle on an older supported JDK.
./gradlew wrapper --gradle-version 8.143Verify
The version output shows the new Gradle and the build starts.
./gradlew --versionConfirmed by docs.gradle.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Flutter Android build fails: Java is too new for this Gradle version
Unsupported class file major version 61
Gradle only runs on Java versions it knows.
3 causes, each with a fixMobile 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 fixMobile apps
Flutter Android build stops with Execution failed for task ':app:…'
Execution failed for task ':app:compileFlutterBuildRelease'.
The line only tells you which Gradle step broke; the task name in the quotes tells you why.
5 causes, each with a fixMobile 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 fixMobile apps
flutter_local_notifications crashes on Android with Integer.intValue() on a null object reference
NullPointerException in setSmallIcon
The crash comes from the small icon.
2 causes, each with a fix