Ionic Production version failed to load on android 4.4.2


#1

When I make a build with production flag in Ionic as follows:

ionic cordova run --prod

It works well in new version of android. but not working in android 4.4.2.
When I debug the app with chrome remote tools facility, I found following error.


Let me share you my package.json:

{
“name”: “newsapp”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“buildprod”: “ionic-app-scripts build --prod”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
"@angular/common": “^4.1.3”,
"@angular/compiler": “^4.1.3”,
"@angular/compiler-cli": “^4.1.3”,
"@angular/core": “^4.1.3”,
"@angular/forms": “^4.1.3”,
"@angular/http": “^4.1.3”,
"@angular/platform-browser": “^4.1.3”,
"@angular/platform-browser-dynamic": “^4.1.3”,
"@ionic-native/admob-free": “^3.10.3”,
"@ionic-native/core": “3.7.0”,
"@ionic-native/device": “^3.10.3”,
"@ionic-native/native-audio": “^3.10.3”,
"@ionic-native/splash-screen": “3.7.0”,
"@ionic-native/status-bar": “3.7.0”,
"@ionic/storage": “2.0.1”,
“ionic-angular”: “3.2.1”,
“ionicons”: “3.0.0”,
“rxjs”: “5.1.1”,
“sw-toolbox”: “3.6.0”,
“zone.js”: “0.8.10”
},
“devDependencies”: {
"@ionic/app-scripts": “^1.3.7”,
"@ionic/cli-plugin-cordova": “1.0.0”,
"@ionic/cli-plugin-ionic-angular": “1.0.0”,
“typescript”: “2.2.1”
},
“description”: “An Ionic project”
}


ionic.config.json

{
“name”: “newsapp”,
“app_id”: “”,
“type”: “ionic-angular”
}


#2

Fix ionic build android --prod not working in older version of android e.g. 4.4.2

Step 1:
write script in package.json as follows:
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“buildprod”: “ionic-app-scripts build --prod”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},

Step 2:
write command:
npm run buildprod

Step 3:
“www” folder will be generated by step 2. so, this is our production version of angular build. Just rename it with www_prod

Step 4:
write command:
npm run build

Step 5:
“www” folder will be generated by step 3. This is our normal version of angular build.

Copy all files from www_prod to www folder except "main.css"
delete "main.js.map"
optional: change absolute url of sourceMappingURL in main.js file

Step 6:
write command:
cordova run android
or cordova build android --release


#3

So you are saying the main.css file of the prod build you made was broken and caused this whole problem?