Why Ionic Shows White Screen After Splash Screen
In this article
Yes, a white screen after the splash screen in an Ionic app usually means the app failed to load the initial page or a plugin blocked execution.
What You'll Need
- Node.js (latest LTS version) and npm installed
- Ionic CLI (npm install -g @ionic/cli)
- A code editor such as VS Code
- Android Studio or Xcode for native builds (optional for debugging)
- Device or emulator to run the app
- Access to the project’s source code (Git repository or local copy)
Step‑by‑Step
- Confirm the app launches on a browser. Run
ionic serve. If the app loads correctly in Chrome or Edge, the problem is likely native‑runtime related rather than pure Angular code. - Check the console for early JavaScript errors. Open the developer tools (F12) and look for red error messages that appear before the splash screen disappears. Errors like
Cannot read property 'add' of undefinedorUncaught (in promise)often stop the Angular bootstrap. - Verify the
index.htmlfile. Ensure the<base href="/">tag is present and points to the correct base path. A missing or wrong base href causes the router to fail loading the first page, resulting in a blank view. - Inspect
app.module.tsfor missing imports. Common culprits are forgottenBrowserModule,IonicModule.forRoot(), or a lazy‑loaded module that throws during construction. Re‑add any omitted imports and rebuild. - Review the
config.xmlorcapacitor.config.jsonfor incorrectserversettings. If you haveserver.urlpointing to a non‑existent dev server, the app will wait forever and eventually show a white screen. - Check native plugins. Run
ionic cordova plugin list(ornpx cap pluginsfor Capacitor). Remove any plugin that was added recently and rebuild. Some plugins require extra permissions or a specific AndroidX version; mismatches cause the WebView to crash silently. - Update the Android/iOS platform. Execute
ionic cordova platform rm android && ionic cordova platform add android@latest(or the Capacitor equivalent). This refreshes Gradle files and ensures the WebView version matches the compiled assets. - Clear the app cache on the device. On Android, go to Settings > Apps > YourApp > Storage > Clear Cache. On iOS, delete the app and reinstall. Cached old bundles can interfere with new builds.
- Re‑build the project. Run
ionic build --prodto generate a production bundle, thenionic capacitor copy android(orionic cordova build android) to push the assets to the native project. - Run the app on a device with remote debugging. Connect the device, open Chrome’s
chrome://inspect, and watch the console logs as the splash screen disappears. Look forFailed to load resourceornet::ERR_FILE_NOT_FOUNDmessages. - Fix any reported errors. Typical fixes include:
- Adding missing environment variables in
.envfiles. - Correcting import paths that differ in case‑sensitive file systems.
- Ensuring all Angular components have a selector and template defined.
- Adding missing environment variables in
- Test again. Restart the device, launch the app, and verify that the home page appears after the splash screen. If the white screen persists, move to the troubleshooting section.
Common Mistakes
- Leaving the
base hreftag empty or pointing to a sub‑folder that does not exist on the device. - Using a development server URL in
capacitor.config.jsonfor a production build. - Adding a plugin without installing its native counterpart (e.g., installing
cordova-plugin-camerabut forgetting to runionic cordova prepare). - Mixing Angular lazy‑loaded routes with incorrect path names, causing the router to throw before the first component renders.
- Running
ionic servewith--no-openand assuming the same behavior on a device; the browser tolerates some errors that the WebView does not.
Tips
- Always test a fresh
ionic buildbefore adding new plugins. A clean build isolates the source of the issue. - Enable Angular’s production mode (
enableProdMode()) only after you have verified that the development build works; production mode suppresses many console warnings that help debugging. - Use
ionic capacitor run android -l --externalto live‑reload on a device; the live‑reload URL replaces the splash screen only after the bundle is successfully fetched. - Keep the WebView version up to date by updating the AndroidX library or iOS WKWebView through the platform‑specific SDK tools.
- Log the app’s bootstrap sequence with
console.log('Bootstrap start')inmain.tsandconsole.log('Bootstrap end')afterplatform.ready(). This helps pinpoint where execution stops.
Troubleshooting
If the white screen remains after following the steps above, try the following systematic checks.
- Restart the device. Some Android devices keep a stale WebView process that does not release memory.
- Update Ionic CLI and Cordova/Capacitor. Run
npm i -g @ionic/cliandnpm i @capacitor/core@latest @capacitor/cli@latest. Compatibility issues between CLI and platform libraries can cause silent crashes. - Check the native logs. Use
adb logcat | grep -i ionic(Android) or Xcode’s console (iOS). Look forFatal ExceptionorWebView: Failed to load URLentries. - Disable all plugins temporarily. Comment out
cordova.pluginsorCapacitor.Pluginsimports, rebuild, and test. If the app loads, re‑enable plugins one by one to isolate the offender. - Verify the build output. Open
www/index.htmlinside the built Android APK (useapktoolto unzip) and ensure the bundledmain.jsandpolyfills.jsfiles are present and not empty. - Use a fallback splash screen. In
capacitor.config.json, setbackgroundColorandlaunchShowDurationto a short value (e.g., 2000 ms). This forces the app to hide the splash screen earlier, revealing any underlying errors in the console. - Re‑install the app. Delete the app from the device, run
ionic capacitor sync android, and reinstall. This clears any corrupted native assets. - Consider a clean clone. Clone the repository into a new folder, run
npm ci(clean install), and repeat the build steps. This eliminates hidden local configuration problems. - Contact support with logs. If none of the above resolves the issue, gather the
adb logcatoutput, thenpm debug log, and the version numbers of Ionic, Cordova/Capacitor, and the platform SDKs. Provide these details when asking for help on the Ionic Forum or Stack Overflow.
Frequently Asked Questions
Why does the white screen only appear on Android and not on iOS?
Android’s WebView is more sensitive to missing native libraries and to mismatched Gradle dependencies. iOS uses WKWebView, which often tolerates missing plugins more gracefully.
Can the splash screen duration cause the white screen?
No. The splash screen simply hides the UI; the white screen appears after it is dismissed when the app fails to render the first page.
Is disabling Angular’s zone.js a fix?
Disabling zone.js is not recommended because Ionic relies on it for change detection. Removing it will likely cause more UI issues rather than solve the white screen.
Do I need to clear the browser cache on the device?
Clearing the app’s cache (Settings > Apps > YourApp > Storage > Clear Cache) can resolve cases where an old bundle is still being served.
What if the app works in ionic serve but not after ionic build --prod?
Production builds enable minification and tree‑shaking, which can remove code that is actually required at runtime. Check for any code that is referenced only by string literals or dynamic imports and add explicit imports.
Can a corrupted package-lock.json cause this?
Yes. Deleting node_modules and the lock file, then running npm install ensures a clean dependency tree.