Blank Screen - Angular JIT compilation failed: '@angular/compiler' not loaded
Asked Answered
A

1

0

I'm currently having trouble getting my Ionic 5 along with Angular 9 project to work.

ionic cordova run android works great

but as soon i run ionic cordova run android --prod the only thing i get is a blank screen.

Output from chrome dev tools:

Error: Angular JIT compilation failed: '@angular/compiler' not loaded!
  - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
  - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?

  - Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.
    at J (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Function.get (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Gt (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Ji (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at Yi.processProvider (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at Array.forEach (<anonymous>)
    at Ot (main-es2015.a75ef42b05ed5a68eecb.js:1)

I already checked the following solution approaches, but none of them worked for my project:

if i set aot and buildOptimizer to false in angular.js i can run ionic cordova run android --prod without any error, but when i then try to generate an apk with ionic cordova build android --prod --release and open it, the screen is blank again.

My current dependencies in package.json are:

  "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@auth0/angular-jwt": "^4.1.2",
    "@capacitor/core": "3.0.0",
    "@ionic-native/app-version": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/device": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/ionic-webview": "^5.36.0",
    "@ionic-native/local-notifications": "^5.36.0",
    "@ionic-native/native-audio": "^5.36.0",
    "@ionic-native/network": "^5.36.0",
    "@ionic-native/screen-orientation": "^5.36.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.36.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage": "^2.3.1",
    "@types/google-maps": "^3.2.2",
    "@types/hammerjs": "^2.0.39",
    "compare-func": "^2.0.0",
    "cordova-android": "^9.0.0",
    "cordova-ios": "^5.1.1",
    "cordova-plugin-androidx": "^2.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device-name": "^1.3.5",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.3.1",
    "cordova-plugin-inappbrowser": "^4.1.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-local-notification": "^0.9.0-beta.2",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-wkwebviewxhrfix": "git+https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git",
    "cordova-support-google-services": "^1.3.2",
    "es6-promise-plugin": "^4.2.2",
    "hammerjs": "^2.0.8",
    "ionic-pullup": "^5.0.0-beta.3",
    "ionic2-calendar": "^0.6.9",
    "phonegap-plugin-multidex": "^1.0.0",
    "rxjs": "~6.5.1",
    "rxjs-compat": "^6.5.5",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },

M< environment looks like:

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 5.9.1
   @angular-devkit/build-angular : 0.901.15
   @angular-devkit/schematics    : 9.1.15
   @angular/cli                  : 9.1.15
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 9.0.0 ([email protected])
   Cordova Platforms : android 8.1.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 18 other plugins)

Am i missing something? Any help is welcome!

Arriviste answered 24/11, 2021 at 14:52 Comment(0)
A
1

I got everything working after following these steps:

  • renamed folders node_modules, www and platforms/android (for backup reasons)
  • npm install
  • ionic cordova prepare android
  • ionic cordova run android --prod
Arriviste answered 28/11, 2021 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.