Skip to content

Uncaught SyntaxError in vendor.js when running on Android #15038

Closed

Description

@hebra

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.

Activity

  1. hebra commented on Aug 6, 2018

    @hebra
    Author

    As an additional information: the first line where the const keyword occurs in the vendor.js from the android apk file seems to be some Ionic-specific initialization:

    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;
    }
    
  2. hebra commented on Aug 9, 2018

    @hebra
    Author

    Updated to the latest Ionic 4 Beta 2 release this morning - problem still persists.

    Created a new test project via ionic start i4a6-app tabs --type=angular and run it on the emulator (and a test Android device).

    ionic info
    
    Ionic:
    
       ionic (Ionic CLI)          : 4.0.5 (/usr/local/lib/node_modules/ionic)
       Ionic Framework            : @ionic/angular 4.0.0-beta.2
       @angular-devkit/core       : 0.7.2
       @angular-devkit/schematics : 0.7.2
       @angular/cli               : 6.1.2
       @ionic/ng-toolkit          : 1.0.5
       @ionic/schematics-angular  : 1.0.4
    
    Cordova:
    
       cordova (Cordova CLI) : 8.0.0
       Cordova Platforms     : android 7.0.0
    
    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.3.0
       OS                : macOS High Sierra
       Xcode             : Xcode 9.4.1 Build version 9F2000
    
    Environment:
    
       ANDROID_HOME : /Users/heb/Library/Android/sdk
    

    One other thing I found is: when I rollback my project to Ionic 3 and Angular 5 the whole thing works w/o any issue even though the vendor.js also has plenty of 'use strict' and 'const' uses.

  3. hebra commented on Aug 9, 2018

    @hebra
    Author

    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

  4. timhill1989 commented on Aug 9, 2018

    @timhill1989

    Same issue for me. I know this behaviour existed in the past as well with older Android Versions. We used to use Crosswalk in those projects, targeting Android 4.xx.

    Right now, Android > 5.1 works for me. But lower doesnt

  5. hebra commented on Aug 9, 2018

    @hebra
    Author

    @timhill1989 can you share your project files (config.xml, package.json etc.) of the project which works for you? Also which Android SDK version are you using?

  6. timhill1989 commented on Aug 9, 2018

    @timhill1989

    Let me know if you need other information.

    Started from empty template, not much functionality added yet.

    API 22 Emulator/Device throws error
    Api 27 Emulator/Device works

    Ionic:
    
       ionic (Ionic CLI)          : 4.0.3 (C:\Users\t.hill\AppData\Roaming\npm\node_modules\ionic)
       Ionic Framework            : @ionic/angular 4.0.0-beta.2
       @angular-devkit/core       : 0.7.0-rc.3
       @angular-devkit/schematics : 0.7.0-rc.3
       @angular/cli               : 6.0.8
       @ionic/ng-toolkit          : 1.0.2
       @ionic/schematics-angular  : 1.0.1
    
    Cordova:
    
       cordova (Cordova CLI) : 8.0.0
       Cordova Platforms     : android 7.0.0
    
    System:
    
       Android SDK Tools : 26.1.1
       NodeJS            : v9.8.0 (C:\Program Files\nodejs\node.exe)
       npm               : 6.2.0
       OS                : Windows 10
    
    

    config.xml

    <?xml version='1.0' encoding='utf-8'?>
    <widget id="xxx" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
        <name>xxx</name>
        <description>xxx</description>
        <author email="xxx" href="xxx">xxx</author>
        <content src="index.html" />
        <access origin="*" />
        <allow-intent href="http://*/*" />
        <allow-intent href="https://*/*" />
        <allow-intent href="tel:*" />
        <allow-intent href="sms:*" />
        <allow-intent href="mailto:*" />
        <allow-intent href="geo:*" />
        <preference name="ScrollEnabled" value="false" />
        <preference name="android-minSdkVersion" value="19" />
        <preference name="BackupWebStorage" value="none" />
        <preference name="SplashMaintainAspectRatio" value="true" />
        <preference name="FadeSplashScreenDuration" value="300" />
        <preference name="SplashShowOnlyFirstTime" value="true" />
        <preference name="SplashScreen" value="screen" />
        <preference name="SplashScreenDelay" value="3000" />
        <platform name="android">
            <allow-intent href="market:*" />
            <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
            <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
            <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
            <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
            <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
            <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
            <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
            <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
            <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
            <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png" />
            <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png" />
            <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png" />
            <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
            <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
            <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
            <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
            <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
            <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
        </platform>
        <plugin name="cordova-plugin-whitelist" spec="1.3.3" />
        <plugin name="cordova-plugin-device" spec="2.0.2" />
        <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
        <plugin name="cordova-plugin-ionic-webview" spec="^2.0.0" />
        <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
        <plugin name="cordova-plugin-file" spec="^6.0.1" />
        <plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
        <engine name="android" spec="7.0.0" />
        <allow-navigation href="http://172.28.1.243:8100" />
    </widget>
    
    

    package.json

    
    {
      "name": "xxx",
      "version": "0.0.1",
      "author": "T.Hill",
      "homepage": "xxx",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/common": "6.0.9",
        "@angular/core": "6.0.9",
        "@angular/forms": "6.0.9",
        "@angular/http": "6.0.9",
        "@angular/platform-browser": "6.0.9",
        "@angular/platform-browser-dynamic": "6.0.9",
        "@angular/router": "6.0.9",
        "@ionic-native/android-permissions": "^5.0.0-beta.14",
        "@ionic-native/core": "5.0.0-beta.14",
        "@ionic-native/file": "5.0.0-beta.14",
        "@ionic-native/splash-screen": "5.0.0-beta.14",
        "@ionic-native/status-bar": "5.0.0-beta.14",
        "@ionic/angular": "4.0.0-beta.2",
        "@ionic/ng-toolkit": "1.0.2",
        "@ionic/schematics-angular": "1.0.1",
        "cordova-android": "7.0.0",
        "cordova-plugin-android-permissions": "^1.0.0",
        "cordova-plugin-device": "^2.0.2",
        "cordova-plugin-file": "^6.0.1",
        "cordova-plugin-ionic-keyboard": "^2.1.2",
        "cordova-plugin-ionic-webview": "^2.0.2",
        "cordova-plugin-splashscreen": "^5.0.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "core-js": "^2.5.3",
        "rxjs": "6.2.2",
        "zone.js": "^0.8.26"
      },
      "devDependencies": {
        "@angular/cli": "6.0.8",
        "@angular/compiler": "6.0.9",
        "@angular/compiler-cli": "6.0.9",
        "@angular/language-service": "6.0.9",
        "@angular-devkit/architect": "0.7.0-rc.3",
        "@angular-devkit/build-angular": "0.7.0-rc.3",
        "@angular-devkit/core": "0.7.0-rc.3",
        "@angular-devkit/schematics": "0.7.0-rc.3",
        "@types/jasmine": "~2.8.6",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~10.5.2",
        "codelyzer": "~4.4.2",
        "jasmine-core": "~2.99.1",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~2.0.2",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.0",
        "karma-jasmine": "~1.1.1",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.4.0",
        "ts-node": "~7.0.0",
        "tslint": "~5.11.0",
        "typescript": "~2.7.2"
      },
      "description": "xxx",
      "cordova": {
        "plugins": {
          "cordova-plugin-file": {},
          "cordova-plugin-whitelist": {},
          "cordova-plugin-device": {},
          "cordova-plugin-splashscreen": {},
          "cordova-plugin-ionic-webview": {},
          "cordova-plugin-ionic-keyboard": {},
          "cordova-plugin-android-permissions": {}
        },
        "platforms": [
          "android"
        ]
      }
    }
    
    
  7. hebra commented on Aug 9, 2018

    @hebra
    Author

    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.

  8. hebra commented on Aug 10, 2018

    @hebra
    Author

    After some testing with different SDK versions and emulators I can confirm that the minimum version as of now has to be SDK 25 (Android 7.1.1 Nougat). Anything older, even Android 7.0 (SDK 24) will not work with the current Ionic 4 beta release.

  9. unit-cesar commented on Aug 14, 2018

    @unit-cesar

    Just contributing. My tests with API 23, 24, 25, 26 and 27 using AVD (Android Studio) and Genymotion:

    Nexus_5X_API_23_-_Marshmallow_6.0:
    Doesn't work on AVD (Android Studio) and Genymotion. White screen!

    Nexus_5X_API_24_-_Nougat_7.0:
    Doesn't work on AVD (Android Studio) and Genymotion. White screen!

    Nexus_5X_API_25_Nougat_7.1.1: Works in parts!
    On Genymotion: Doesn't work. White screen!
    On AVD (Android Studio):
    The new tag <ion-img> does not show the image, I had to go back to the old tag:

    <!--<ion-img [src]="item.imagem" [routerLink]="'/detail/' + item.id"></ion-img>-->
    <img [src]="item.imagem" [routerLink]="'/detail/' + item.id">
    

    Nexus_5X_API_26_-_Oreo_8.0: It works!
    Works on AVD (Android Studio) and Genymotion

    Nexus_5X_API_27_-8.1-_Oreo:
    On Genymotion: Doesn't exist.
    On AVD (Android Studio): It works!

    It's a huge range of devices out of target.
    The difficulty is of the devices? Or Ionic engineering?
    Can we expect improvements in version 4 to achieve at least API 23?

  10. unit-cesar commented on Aug 14, 2018

    @unit-cesar

    About my system:
    image

  11. snowyu commented on Aug 28, 2018

    @snowyu

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

  12. snowyu commented on Aug 28, 2018

    @snowyu
  13. unit-cesar commented on Aug 28, 2018

    @unit-cesar

    The switch to es2017 happened in this commit:
    06ad60e

  14. unit-cesar commented on Aug 29, 2018

    @unit-cesar

    Perfect @snowyu

    In Genymotion I tested with API 23 (Marshmallow 6.0), I enabled the PlayStore and then I installed the Webview Android System, it works !!!

    We should try to guide the user to install or update the Webview Android System. Add a function in index.html, if the application doesn't load?

    image

  15. 6 remaining items

  16. lemosen commented on Sep 25, 2018

    @lemosen

    I have a same problem

  17. mictay commented on Sep 29, 2018

    @mictay

    Same issue White Screen

    Uncaught SyntaxError: Use of const in strict mode. vendor.js:97238
    
    √ Gathering environment info - done!
    
    Ionic:
    
       ionic (Ionic CLI)          : 4.1.2 (C:\Users\micha\AppData\Roaming\npm\node_m       odules\ionic)
       Ionic Framework            : @ionic/angular 4.0.0-beta.7
       @angular-devkit/core       : 0.7.5
       @angular-devkit/schematics : 0.7.5
       @angular/cli               : 6.1.5
       @ionic/ng-toolkit          : 1.0.8
       @ionic/schematics-angular  : 1.0.6
    
    Cordova:
    
       cordova (Cordova CLI) : 8.0.0
       Cordova Platforms     : android 7.0.0
       Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-i       onic-webview 2.1.4, (and 5 other plugins)
    
    System:
    
       Android SDK Tools : 26.1.1 (E:\Android\sdk)
       NodeJS            : v8.11.3 (E:\Program Files\nodejs\node.exe)
       npm               : 5.6.0
       OS                : Windows 10
    
  18. hiepxanh commented on Nov 6, 2018

    @hiepxanh
    Contributor

    tracking issue here, causing of transplie module PROPER PACKAGE FOR ANGULAR #15191

  19. raphjutras commented on Nov 13, 2018

    @raphjutras

    Bump.. huge blocker for me. I would like to support Android 5.0 and UP.. This is just 'too' important to ignore... We are currently developing on Ionic 4 Beta 15 and wanted to release when Ionic 4 is officially out, Will it support Android 5?

  20. hebra commented on Nov 14, 2018

    @hebra
    Author

    @raphjutras the only way I see right now for 5.0 is to use Ionic 3 and to not upgrade to 4.

  21. raphjutras commented on Nov 14, 2018

    @raphjutras

    @hebra You think that when they will release "official" version of Ionic 4, they will not support Android 5!?
    Or you mean 'right now' ..?

  22. hiepxanh commented on Nov 14, 2018

    @hiepxanh
    Contributor

    @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

  23. raphjutras commented on Nov 14, 2018

    @raphjutras

    Ohhh, thank you :)

  24. nextbyn commented on Nov 23, 2018

    @nextbyn

    Same issue with

    `Ionic:

    ionic (Ionic CLI) : 4.0.0 (C:\Users\exe\AppData\Roaming\nvm\v8.11.2\node_modules\ionic)
    Ionic Framework : ionic-angular 3.9.2
    @ionic/app-scripts : 3.2.0

    Cordova:

    cordova (Cordova CLI) : 8.1.2 ([email protected])
    Cordova Platforms : android 7.1.2

    System:

    NodeJS : v8.11.3 (C:\Program Files\nodejs\node.exe)
    npm : 5.6.0
    OS : Windows 10`

    Result:
    White screen!

    with ionic 3.9.2 when do 'ionic cordova run android' get white screen error and on console show Uncaught SyntaxError: Unexpected token function
    any help is appreciate

    the error in fact is this async await word!
    async customfunction() { <---code----> }

  25. ionitron-bot commented on Nov 29, 2018

    @ionitron-bot

    This issue has been automatically identified as an Ionic 3 issue. We recently moved Ionic 3 to its own repository. I am moving this issue to the repository for Ionic 3. Please track this issue over there.

    If I've made a mistake, and if this issue is still relevant to Ionic 4, please let the Ionic Framework team know!

    Thank you for using Ionic!

  26. ionitron-bot commented on Nov 29, 2018

    @ionitron-bot

    Issue moved to: ionic-team/ionic-v3#658

  27. locked and limited conversation to collaborators on Nov 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions