Gluon应用在移动设备无法运行且出现黑屏问题求助
Hey there, let's figure out why your Gluon app is showing a black screen on your Redmi Note 8 Pro. I've dealt with similar headaches on Xiaomi devices and older JDK versions, so here are actionable steps to fix this:
Gluon Mobile has specific version requirements tied to JDK releases. JDK 8u231 works best with Gluon Charm versions 5.0.2 or later. Double-check your build config (either build.gradle for Gradle or pom.xml for Maven) to ensure you're using a compatible version:
// Example Gradle dependency dependencies { implementation 'com.gluonhq:charm:5.0.2' }
If you're on an older Gluon version, upgrading might resolve runtime rendering conflicts.
Xiaomi's MIUI loves to optimize apps to save battery, but this often breaks JavaFX/Gluon apps by restricting their access to system resources. Here's how to fix it:
- Open Settings > Apps > Manage Apps > [Your Gluon App] > Advanced
- Toggle off Disable MIUI optimization (yes, the wording is counterintuitive—turning this off disables the optimizations that are causing issues)
- Restart your device, then launch the app again. This is the most common fix for black screens on Xiaomi devices.
The Prism engine (which Gluon uses for rendering) can have issues with certain GPUs. You can force software rendering or specify a different renderer via VM arguments:
- To force software rendering (often fixes GPU-related black screens), add this to your Android build config:
jfxmobile { android { vmArgs = ['-Dprism.order=sw'] } } - If software rendering is too slow, try forcing OpenGL ES 2.0 with
-Dprism.order=es2instead. Test both options to see which works for your device.
Even if your app doesn't use them directly, some Gluon components need basic permissions to initialize properly. Add these to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Missing permissions can cause silent initialization failures that result in a black screen.
JDK 8u231 is quite old, and there are known bugs in its JavaFX runtime that affect Android rendering. Updating to the latest JDK 8 patch (like 8u371) can resolve these underlying issues. Rebuild your app after updating the JDK to see if the black screen goes away.
内容的提问来源于stack exchange,提问作者Manuel Ankner

