White screen after splash screen in Ionic 6 production build and 'Error: JIT compiler unavailable'

When I try to build the app in release mode:
$ ionic capacitor build android --prod

The Android project is produced fine and I can create an .apk/deploy to a device or emulator. The app shows a splash screen and then goes to white forever. This is what Chrome dev tools show:

onscript loading complete
main.64f759d589c2bca6.js:1 Error: JIT compiler unavailable
    at Kr (main.64f759d589c2bca6.js:1)
    at Function.get (main.64f759d589c2bca6.js:1)
    at pi (main.64f759d589c2bca6.js:1)
    at Ch (main.64f759d589c2bca6.js:1)
    at Td (main.64f759d589c2bca6.js:1)
    at Tm.processProvider (main.64f759d589c2bca6.js:1)
    at main.64f759d589c2bca6.js:1
    at main.64f759d589c2bca6.js:1
    at Array.forEach (<anonymous>)
    at Fi (main.64f759d589c2bca6.js:1)

Without the release/prod flag the app works fine and shows its content a couple of seconds after the splash screen.

Any ideas on how to debug this? Is there any way to get a better error message?

1 Like

I am facing the same issue as well. Without the --prod tag, its working properly. But when I use the --prod tag, it gets stuck at the Splash screen. I am still trying to see what can be done to resolve the issue, but haven’t found any solution yet.

What about you?

I’ve come back to this day and managed to fix it. To resolve the issue:

  1. In angular.json I set "aot": true, for the develop configuration
  2. Build without the --prod flag like so: ionic capacitor build android
  3. Run the app in an emulator/device and use Chrome remote dev tools to inspect the console errors chrome://inspect/#devices
  4. Because we built in dev mode, the error is a lot more descriptive. It told me that a specific module (not a third party plugin) in my app was causing the issue and would need to be compiled.
  5. This StackOverflow answer applied in my case: javascript - Uncaught (in promise): Error: Angular JIT compilation failed: '@angular/compiler' not loaded! in angular 9 - Stack Overflow
  6. I was importing HttpClientModule AND HttpClient. I removed HttpClient from my imports to fix the issue.
    imports: [
        HttpClient,
        HttpClientModule,
    ],

to

    imports: [
        HttpClientModule,
    ],