TechBuzzPro

Why Ionic Shows White Screen After Splash Screen

· 6 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step‑by‑Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. 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.
  2. 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 undefined or Uncaught (in promise) often stop the Angular bootstrap.
  3. Verify the index.html file. 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.
  4. Inspect app.module.ts for missing imports. Common culprits are forgotten BrowserModule, IonicModule.forRoot(), or a lazy‑loaded module that throws during construction. Re‑add any omitted imports and rebuild.
  5. Review the config.xml or capacitor.config.json for incorrect server settings. If you have server.url pointing to a non‑existent dev server, the app will wait forever and eventually show a white screen.
  6. Check native plugins. Run ionic cordova plugin list (or npx cap plugins for 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.
  7. 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.
  8. 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.
  9. Re‑build the project. Run ionic build --prod to generate a production bundle, then ionic capacitor copy android (or ionic cordova build android) to push the assets to the native project.
  10. 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 for Failed to load resource or net::ERR_FILE_NOT_FOUND messages.
  11. Fix any reported errors. Typical fixes include:
    • Adding missing environment variables in .env files.
    • Correcting import paths that differ in case‑sensitive file systems.
    • Ensuring all Angular components have a selector and template defined.
  12. 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 href tag empty or pointing to a sub‑folder that does not exist on the device.
  • Using a development server URL in capacitor.config.json for a production build.
  • Adding a plugin without installing its native counterpart (e.g., installing cordova-plugin-camera but forgetting to run ionic cordova prepare).
  • Mixing Angular lazy‑loaded routes with incorrect path names, causing the router to throw before the first component renders.
  • Running ionic serve with --no-open and assuming the same behavior on a device; the browser tolerates some errors that the WebView does not.

Tips

  • Always test a fresh ionic build before 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 --external to 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') in main.ts and console.log('Bootstrap end') after platform.ready(). This helps pinpoint where execution stops.

Troubleshooting

If the white screen remains after following the steps above, try the following systematic checks.

  1. Restart the device. Some Android devices keep a stale WebView process that does not release memory.
  2. Update Ionic CLI and Cordova/Capacitor. Run npm i -g @ionic/cli and npm i @capacitor/core@latest @capacitor/cli@latest. Compatibility issues between CLI and platform libraries can cause silent crashes.
  3. Check the native logs. Use adb logcat | grep -i ionic (Android) or Xcode’s console (iOS). Look for Fatal Exception or WebView: Failed to load URL entries.
  4. Disable all plugins temporarily. Comment out cordova.plugins or Capacitor.Plugins imports, rebuild, and test. If the app loads, re‑enable plugins one by one to isolate the offender.
  5. Verify the build output. Open www/index.html inside the built Android APK (use apktool to unzip) and ensure the bundled main.js and polyfills.js files are present and not empty.
  6. Use a fallback splash screen. In capacitor.config.json, set backgroundColor and launchShowDuration to a short value (e.g., 2000 ms). This forces the app to hide the splash screen earlier, revealing any underlying errors in the console.
  7. Re‑install the app. Delete the app from the device, run ionic capacitor sync android, and reinstall. This clears any corrupted native assets.
  8. 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.
  9. Contact support with logs. If none of the above resolves the issue, gather the adb logcat output, the npm 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.