Ionic 4 and Angular 6: Uncaught SyntaxError in vendor.js when running on Android

#1

I am currently facing a problem when starting an Ionic 4 + Angular 6 when starting the App on any Android device or emulator, but not when running in a browser, an iOS device or via the Ionic DevApp on Android.

By using the emulator and logcat I found the root cause - but have no idea how to fix it.
During startup, after loading the index.html but during parsing vendor.js the following exception is logged:

D/SystemWebChromeClient( 6353): http://localhost:8080/vendor.js: Line 71984 : Uncaught SyntaxError: Use of const in strict mode.
I/chromium( 6353): [INFO:CONSOLE(71984)] “Uncaught SyntaxError: Use of const in strict mode.”, source: http://localhost:8080/vendor.js (71984)
D/CordovaWebViewImpl( 6353): onPageFinished(http://localhost:8080/)

The first line in the vendor.js where a const keyword occurs seems to be some Ionic initialization process:

function setupConfig(config) {
const win = window;
const Ionic = win.Ionic;
if (Ionic && Ionic.config && Ionic.config.constructor.name !== ‘Object’) {
console.error(‘ionic config was already initialized’);
return;
}
win.Ionic = win.Ionic || {};
win.Ionic.config = Object.assign({}, win.Ionic.config, config);
return win.Ionic.config;
}

Did anyone experience such a problem? How can this be solved as it is currently blocking our development for Android.

The full details can be found in the related Github issue: https://github.com/ionic-team/ionic/issues/15038