TypeError: Object prototype may only be an Object or null: undefined after Ionic capacitor run android --prod

I have a problem.

Building with ‘ionic capacitor run android’ works perfectly.

but when run ‘ionic capacitor run android --prod’, the app opens but stuck at splash screen with the error below.

is this a compilation issue and how do I resolve it?

I tried searching for solutions that included updating angular cli and other dependencies but it didn’t work.

$ ionic info

Ionic:

Ionic CLI : 6.12.4 (C:\Users\MSI\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 4.11.13
@angular-devkit/build-angular : 0.803.29
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.3.28
@ionic/angular-toolkit : 2.3.3

Capacitor:

Capacitor CLI : 2.4.2
@capacitor/core : 2.4.2

Cordova:

Cordova CLI : 10.0.0
Cordova Platforms : none
Cordova Plugins : no whitelisted plugins (0 plugins total)

Utility:

cordova-res : not installed
native-run (update available: 1.3.0) : 1.0.0

System:

Android SDK Tools : 26.1.1 (C:\Users\MSI\AppData\Local\Android\Sdk)
NodeJS : v12.16.1 (C:\Program Files\nodejs\node.exe)
npm : 6.14.8
OS : Windows 10

package.json dependencies

“dependencies”: {

"@angular/animations": "^8.2.14",

"@angular/common": "~8.2.14",

"@angular/core": "~8.2.14",

"@angular/forms": "~8.2.14",

"@angular/http": "^7.2.16",

"@angular/localize": "^9.0.0",

"@angular/platform-browser": "~8.2.14",

"@angular/platform-browser-dynamic": "~8.2.14",

"@angular/router": "~8.2.14",

"@biesbjerg/ngx-translate-extract-marker": "^1.0.0",

"@capacitor/android": "^2.4.2",

"@capacitor/core": "2.4.2",

"@capacitor/ios": "^2.4.2",

"@ckeditor/ckeditor5-angular": "^2.0.1",

"@ckeditor/ckeditor5-build-classic": "^23.1.0",

"@fortawesome/angular-fontawesome": "^0.6.1",

"@fortawesome/fontawesome-svg-core": "^1.2.28",

"@fortawesome/free-regular-svg-icons": "^5.13.0",

"@fortawesome/free-solid-svg-icons": "^5.13.0",

"@ionic-native/aes-256": "^4.20.0",

"@ionic-native/app-version": "^5.28.0",

"@ionic-native/barcode-scanner": "^5.21.5",

"@ionic-native/base64-to-gallery": "^5.27.0",

"@ionic-native/camera": "^5.29.0",

"@ionic-native/core": "^5.20.0",

"@ionic-native/device": "^5.20.0",

"@ionic-native/file": "^5.28.0",

"@ionic-native/file-chooser": "^5.20.0",

"@ionic-native/file-opener": "^5.28.0",

"@ionic-native/file-path": "^5.20.0",

"@ionic-native/file-picker": "^5.20.0",

"@ionic-native/file-transfer": "^5.20.0",

"@ionic-native/http": "^5.20.0",

"@ionic-native/insomnia": "^5.23.0",

"@ionic-native/ionic-webview": "^5.20.0",

"@ionic-native/media": "^5.26.0",

"@ionic-native/media-capture": "^5.22.0",

"@ionic-native/native-audio": "^5.26.0",

"@ionic-native/network": "^5.20.0",

"@ionic-native/photo-viewer": "^5.22.0",

"@ionic-native/qr-scanner": "^5.10.0",

"@ionic-native/splash-screen": "^5.20.0",

"@ionic-native/sqlite": "^5.30.0",

"@ionic-native/status-bar": "^5.20.0",

"@ionic-native/streaming-media": "^5.20.0",

"@ionic-native/toast": "^5.20.0",

"@ionic-native/video-editor": "^5.22.0",

"@ionic-native/video-player": "^5.30.0",

"@ionic/angular": "^4.11.13",

"@ionic/app-scripts": "^3.2.4",

"@ionic/storage": "^2.2.0",

"@ngx-translate/core": "^11.0.1",

"@ngx-translate/http-loader": "^4.0.0",

"@sentry/cli": "^1.51.1",

"@types/bcryptjs": "^2.4.2",

"@types/offscreencanvas": "^2019.6.2",

"@types/webgl2": "0.0.5",

"asmcrypto.js": "^2.3.2",

"bcryptjs": "^2.4.3",

"com-sarriaroman-photoviewer": "^1.2.4",

"cordova-android": "8.1.0",

"cordova-android-support-gradle-release": "^3.0.1",

"cordova-base64-to-gallery": "4.1.3",

"cordova-custom-config": "^5.1.0",

"cordova-ios": "^5.1.1",

"cordova-plugin-aes256-encryption": "^2.0.0",

"cordova-plugin-androidx": "^1.0.2",

"cordova-plugin-androidx-adapter": "^1.1.0",

"cordova-plugin-app-version": "^0.1.9",

"cordova-plugin-camera": "^4.1.0",

"cordova-plugin-compat": "^1.2.0",

"cordova-plugin-file": "^6.0.2",

"cordova-plugin-file-opener2": "^3.0.5",

"cordova-plugin-file-transfer": "^1.7.1",

"cordova-plugin-filechooser": "^1.2.0",

"cordova-plugin-filepath": "^1.5.8",

"cordova-plugin-filepicker": "^1.1.6",

"cordova-plugin-insomnia": "^4.3.0",

"cordova-plugin-media": "^5.0.3",

"cordova-plugin-media-capture": "^3.0.3",

"cordova-plugin-nativeaudio": "^3.0.9",

"cordova-plugin-network-information": "^2.0.2",

"cordova-plugin-qrscanner": "^3.0.1",

"cordova-plugin-streaming-media": "^2.2.0",

"cordova-plugin-video-editor": "^1.1.3",

"cordova-plugin-whitelist": "^1.3.4",

"cordova-sqlite-storage": "^4.0.0",

"core-js": "^2.5.4",

"es6-promise-plugin": "^4.2.2",

"ionic-material": "^0.4.1",

"ionic-native": "^2.9.0",

"jose-jwe": "^0.2.2",

"ng2-pdfjs-viewer": "^5.0.7",

"ngx-logger": "^4.1.9",

"ngx-virtual-scroller": "^3.0.3",

"node-forge": "git://github.com/digitalbazaar/forge.git#ef835fafe",

"pbkdf2-sha256": "^1.1.1",

"rxjs": "~6.5.5",

"rxjs-compat": "^6.5.4",

"scrypt-async": "^2.0.1",

"sentry-cordova": "^0.17.0",

"swiper": "^5.4.5",

"text-encoding": "^0.7.0",

"three": "^0.110.0",

"ts-md5": "^1.2.7",

"tslib": "^1.9.0",

"tui-image-editor": "^3.11.0",

"typeorm": "^0.3.0-rc.13",

"webpack": "^4.42.0",

"zone.js": "~0.9.1"

},

“devDependencies”: {

"@angular-devkit/architect": "~0.801.2",

"@angular-devkit/build-angular": "^0.803.28",

"@angular-devkit/core": "~8.1.2",

"@angular-devkit/schematics": "~8.1.2",

"@angular/cli": "8.3.28",

"@angular/compiler": "~8.2.14",

"@angular/compiler-cli": "~8.2.14",

"@angular/language-service": "~8.2.14",

"@biesbjerg/ngx-translate-extract": "^4.2.0",

"@capacitor/cli": "2.4.2",

"@ionic/angular-toolkit": "^2.1.2",

"@types/jasmine": "~3.3.8",

"@types/jasminewd2": "~2.0.3",

"@types/node": "^8.10.59",

"codelyzer": "^5.0.0",

"cordova-plugin-device": "^2.0.3",

"cordova-plugin-ionic-keyboard": "^2.2.0",

"cordova-plugin-ionic-webview": "^4.1.3",

"cordova-plugin-splashscreen": "^5.0.3",

"cordova-plugin-statusbar": "^2.4.3",

"cordova-plugin-video-player": "git+https://github.com/moust/cordova-plugin-videoplayer.git",

"jasmine-core": "~3.4.0",

"jasmine-spec-reporter": "~4.2.1",

"jetifier": "^1.6.6",

"karma": "~4.1.0",

"karma-chrome-launcher": "~2.2.0",

"karma-coverage-istanbul-reporter": "~2.0.1",

"karma-jasmine": "~2.0.1",

"karma-jasmine-html-reporter": "^1.5.2",

"protractor": "^5.4.3",

"ts-node": "~7.0.0",

"tslint": "~5.15.0",

"typescript": "~3.5.3"

},

“description”: “An Ionic project”,

“cordova”: {

"plugins": {

  "cordova-plugin-statusbar": {},

  "cordova-plugin-device": {},

  "cordova-plugin-splashscreen": {},

  "cordova-plugin-ionic-webview": {

    "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"

  },

  "cordova-plugin-ionic-keyboard": {},

  "cordova-plugin-file": {},

  "cordova-sqlite-storage": {},

  "com-sarriaroman-photoviewer": {},

  "cordova-plugin-streaming-media": {},

  "cordova-plugin-network-information": {},

  "cordova-plugin-filechooser": {},

  "cordova-plugin-filepath": {},

  "cordova-plugin-file-transfer": {},

  "cordova-plugin-aes256-encryption": {},

  "cordova-plugin-filepicker": {},

  "cordova-plugin-qrscanner": {},

  "cordova-plugin-app-version": {},

  "cordova-plugin-camera": {

    "ANDROID_SUPPORT_V4_VERSION": "27.+"

  },

  "cordova-plugin-media-capture": {},

  "cordova-plugin-video-editor": {},

  "cordova-plugin-androidx-adapter": {},

  "cordova-plugin-compat": {},

  "cordova-android-support-gradle-release": {

    "ANDROID_SUPPORT_VERSION": "27.+"

  },

  "cordova-plugin-androidx": {},

  "cordova-custom-config": {},

  "cordova-plugin-file-opener2": {

    "ANDROID_SUPPORT_V4_VERSION": "27.+"

  },

  "cordova-plugin-insomnia": {},

  "sentry-cordova": {

    "SENTRY_ANDROID_SDK_VERSION": "1+"

  },

  "cordova-plugin-whitelist": {},

  "cordova-plugin-nativeaudio": {},

  "cordova-plugin-media": {

    "KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE": "NO"

  },

  "cordova-base64-to-gallery": {},

  "com.moust.cordova.videoplayer": {}

},

"platforms": [

  "android",

  "ios"

]

}

Run ionic build —prod

And look at the errors, if at all

Or run ionic serve with the —prod flag and debug

U know the angular compiler works different when running prod? So I use that to find some difficult errors related to aot template issues

@Tommertom thanks for your reply…I’m doing that right now.