How to suppress "Restricted method called: java.lang.System::load" warning when using native-platform in Gradle on JDK 22+
01:45 05 Aug 2025

I'm working with Gradle 8.12 and Java 22, and I'm encountering the following warning during build:

WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader...
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning...
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

I understand this relates to Java's native access restrictions introduced in newer JDKs. I'm trying to silence the warning by setting:

--enable-native-access=ALL-UNNAMED

However, I'm unsure of the best way to add this JVM argument to Gradle. Should it go in gradle.properties, as an environment variable, or somewhere else? Also, is this the recommended way for builds using native-platform?

Any guidance on where exactly to configure this in a Gradle project (and whether this approach is safe/portable) would be appreciated!

java android flutter gradle build