ionic-framework: Uncaught SyntaxError in vendor.js when running on Android

Bug Report

Ionic Info Run ionic info from a terminal/cmd prompt and paste the output below.

Ionic:

   ionic (Ionic CLI)          : 4.0.3 (/usr/local/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.1
   @angular-devkit/core       : 0.7.2
   @angular-devkit/schematics : 0.7.2
   @angular/cli               : 6.1.2
   @ionic/ng-toolkit          : 1.0.2
   @ionic/schematics-angular  : 1.0.3

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.1, ios 4.5.5

System:

   Android SDK Tools : 26.1.1
   ios-deploy        : 2.0.0
   NodeJS            : v10.8.0 (/usr/local/Cellar/node/10.8.0/bin/node)
   npm               : 6.2.0
   OS                : macOS High Sierra
   Xcode             : Xcode 9.4.1 Build version 9F2000

Environment:

   ANDROID_HOME : /Users/heb/Library/Android/sdk

Describe the Bug Even the simplest myApp Ionic4/Angular6 demo does not proceed past the loading index.html when running on Android (device or emulator). Browser and iOS are fine.

Steps to Reproduce Steps to reproduce the behavior: 0. Make sure an Android SDK is installed and in the PATH and env variables

  1. Create a test app, e.g. via ionic start myApp tabs --type=angular
  2. Start logcat e.g. from command line via adb logcat
  3. Add the Android platform via ionic cordova platform add android
  4. Run ionic cordova emulate android
  5. App starts but shows a blank white page (which is the index.html)

Related Log During app start up in the emulator the logcat logs the following error which I think is the root cause for the app not continuing loading.

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/)

Expected Behavior App should finish starting up.

Additional Context This error only happens on Android devices and the emulator, but not when starting the app on Android via the Ionic DevApp tool.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (2 by maintainers)

Most upvoted comments

I found the reason: the compiled code of @ionic/angular is not the es5 code. It use the new async/await keyword in ES2017.

Thanks @timhill1989 - I can confirm that it is actually working with Android 8.x but not any older version. Considering the current market share for Oreo of just 10% I see this as a blocker for Ionic 4 right now. At least 6 (23%) & 7 (34%) have to be supported as well, better include 5 (15%) as well.

@raphjutras they will support but not now, they are working on it and will release with ionic 4 final. tracking at here IONIC 4 WON’T WORK IN ANDROID 5. It been move from in process to on desk image

@CesarDevesa I download and install it from https://www.apkmirror.com/apk/google-inc/android-system-webview/ directly on Android 6. But it seems no useful(still use the old webview), maybe MUST HAVE GOOGLE PLAY.

The right way should transpile code to es5. I change the @ionic/core and @ionic/angular source target to es5 and add the es5 to lib in the tsconfig. Now the es5 code is in the dist folder of the core and angular package. But It is still output async in the project. Maybe is it a bug in angular-cli? I am not good at angular or typescript. Could @manucorporat check it?

For reference here are the project configuration files for the test project I created (the Android platform and node_modules folders have been removed to reduce file size). i4a6-app.zip