Ionic Android 5.1.1 SyntaxError: Use of const in strict mode

Hi,
I have this runtime error on android devices 5.1.1 or 4.4.2
After splashscreen the app remain on a white page.
The errors that I found are :
02-23 16:41:33.020 4088-4088/com.farmamob.farmaciafavarin D/SystemWebChromeClient: file:///android_asset/www/index.html: Line 10 : Viewport argument key “viewport-fit” not recognized and ignored.
02-23 16:41:33.020 4088-4088/com.farmamob.farmaciafavarin I/chromium: [INFO:CONSOLE(10)] “Viewport argument key “viewport-fit” not recognized and ignored.”, source: file:///android_asset/www/index.html (10)
02-23 16:41:33.030 4088-4088/com.farmamob.farmaciafavarin D/JsMessageQueue: Set native->JS mode to EvalBridgeMode
02-23 16:41:33.300 4088-4088/com.farmamob.farmaciafavarin D/SystemWebChromeClient: file:///android_asset/www/build/vendor.js: Line 1 : Uncaught SyntaxError: Use of const in strict mode.
02-23 16:41:33.300 4088-4088/com.farmamob.farmaciafavarin I/chromium: [INFO:CONSOLE(1)] “Uncaught SyntaxError: Use of const in strict mode.”, source: file:///android_asset/www/build/vendor.js (1)
02-23 16:41:33.300 4088-4088/com.farmamob.farmaciafavarin D/SystemWebChromeClient: file:///android_asset/www/build/main.js: Line 1 : Uncaught ReferenceError: webpackJsonp is not defined
02-23 16:41:33.300 4088-4088/com.farmamob.farmaciafavarin I/chromium: [INFO:CONSOLE(1)] “Uncaught ReferenceError: webpackJsonp is not defined”, source: file:///android_asset/www/build/main.js (1)

My Ionic info is :
cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.1.2
Cordova Platforms  : android 7.0.0 browser 5.0.3 ios 4.5.4
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.0
ios-sim           : 5.0.13
Node              : v9.4.0
npm               : 5.6.0
OS                : macOS Sierra
Xcode             : Xcode 9.2 Build version 9C40b

Environment Variables:

ANDROID_HOME : /Users/cristianpuscasiu/Library/Android/sdk

Misc:

backend : pro

My package.json is :slight_smile:
{
“name”: “Farmacia-Favarin”,
“version”: “1.0.0”,
“author”: “CrisPSoft”,
“homepage”: “www.farmamob.it”,
“private”: true,
“config”: {
“ionic_webpack”: “./config/webpack.config.js”
},
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build --webpack ./config/webpack.config.js”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build --webpack ./config/webpack.config.js”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
"@angular/common": “5.0.1”,
"@angular/compiler": “5.0.1”,
"@angular/compiler-cli": “5.0.1”,
"@angular/core": “5.0.1”,
"@angular/forms": “5.0.1”,
"@angular/http": “5.0.1”,
"@angular/platform-browser": “5.0.1”,
"@angular/platform-browser-dynamic": “5.0.1”,
"@aspnet/signalr-client": “^1.0.0-alpha2-final”,
"@ionic-native/camera": “^4.5.2”,
"@ionic-native/core": “4.4.0”,
"@ionic-native/device": “^4.5.2”,
"@ionic-native/file": “^4.5.2”,
"@ionic-native/file-path": “^4.5.2”,
"@ionic-native/push": “^4.5.2”,
"@ionic-native/splash-screen": “4.4.0”,
"@ionic-native/status-bar": “4.4.0”,
"@ionic/storage": “^2.1.3”,
“cordova-android”: “7.0.0”,
“cordova-android-support-gradle-release”: “^1.2.0”,
“cordova-browser”: “5.0.3”,
“cordova-ios”: “4.5.4”,
“cordova-plugin-camera”: “^4.0.1”,
“cordova-plugin-device”: “^1.1.7”,
“cordova-plugin-file”: “^6.0.1”,
“cordova-plugin-filepath”: “^1.1.0”,
“cordova-plugin-ionic-webview”: “^1.1.16”,
“cordova-plugin-splashscreen”: “^4.1.0”,
“cordova-plugin-whitelist”: “^1.3.3”,
“cordova-sqlite-storage”: “^2.2.0”,
“ionic-angular”: “3.9.2”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“phonegap-plugin-push”: “^2.1.2”,
“rxjs”: “5.5.2”,
“sw-toolbox”: “3.6.0”,
“zone.js”: “0.8.18”
},
“devDependencies”: {
"@ionic/app-scripts": “3.1.2”,
“typescript”: “2.4.2”
},
“description”: “An Ionic project”,
“cordova”: {
“plugins”: {
“cordova-sqlite-storage”: {},
“cordova-plugin-camera”: {},
“cordova-plugin-file”: {},
“cordova-plugin-filepath”: {},
“ionic-plugin-keyboard”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-ionic-webview”: {},
“phonegap-plugin-push”: {
“SENDER_ID”: “997597322709”
},
“cordova-plugin-whitelist”: {},
“cordova-android-support-gradle-release”: {
“ANDROID_SUPPORT_VERSION”: “25.+”
}
},
“platforms”: [
“browser”,
“ios”,
“android”
]
}
}

I tried to compile with --prod but doesn’t change the error.

Anybody can help me?
Thanks,
Cristian

1 Like

Hello,

I meet the same issue, have you found a solution ?

Thanks!

1 Like

Hello,

do you found any solutions ?

Yes. I resolved my bug… I don’t remember exactly how…
I remember that I compiled in debug … and on the error you saw the line in vendor.js or main.js where is crached.
Has a problem of my code or one of the plugin that I used…

Cristian

I can find in my GIT history that I had to do 2 things to solve issues with old Android phones:

  • change new Headers({'Content-Type': 'application/json'}) to new HttpHeaders().set('Content-Type', 'application/json');
  • create a new project using the /src folder

The Solution for me was that I had some plugin that stop the cordova platform add to adding all the necessary plugin. So removing that plugin solved my problem. (this was the in-app-purchase for me)

there was only a little “warn” on the console without anything else