1
votes

I'm getting this error when I run the app on Android 6 or 7 and android Oreo (8.1)

This is the error that shows in the console from logcat

 1-23 10:02:18.208 24346-24346/chess.pidoweb I/chromium: [INFO:CONSOLE(10)] "The key "viewport-fit" is not recognized and ignored.", source: file:///android_asset/www/index.html (10)
11-23 10:02:18.644 24346-24354/? I/zygote64: Ignoring second debugger -- accepting and dropping
11-23 10:02:18.880 24346-24428/? W/chromium: [WARNING:sqlite_persistent_cookie_store.cc(851)] Cookie database is too new.
11-23 10:02:18.881 24346-24428/? W/chromium: [WARNING:sqlite_persistent_cookie_store.cc(851)] Cookie database is too new.
11-23 10:02:23.006 24346-24364/? V/FA: Inactivity, disconnecting from the service
11-23 10:02:24.519 24346-24346/? I/chromium: [INFO:CONSOLE(588)] **"Uncaught SyntaxError: Unexpected identifier", source: file:///android_asset/www/build/main.js (588)**
11-23 10:02:24.546 24346-24346/? D/XWalkCordovaUiClient: onPageLoadStopped(file:///android_asset/www/index.html)
11-23 10:02:24.546 24346-24346/? D/CordovaWebViewImpl: onPageFinished(file:///android_asset/www/index.html)
11-23 10:02:26.572 24346-24346/? W/zygote64: Attempt to remove non-JNI local reference, dumping thread

Steps to Reproduce

run the project on the device android [Android APi 23 to 27 get the same problem] with the comand ->ionic cordova run android

Related Code

the line [588] is this-> async revisa_sincro() { < .....code....> }

Expected Behavior

So, the real issue is this [async ] keyword that stop the app and showme white screen and this error on console Uncaught SyntaxError. If I remove every async code the app runs OK. but I really need this async !!!

Additional Context How I cant get to solve this problem, there is any workaround ?

Ionic Info

    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

Packaje.json

  {
  "name": "pidoionic",
  "version": "0.0.10",
  "description": "",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "config": {
    "ionic_webpack": "config/webpack.config.js"
  },
  "dependencies": {
    "@agm/core": "^1.0.0-beta.3",
    "@angular/animations": "7.1.0",
    "@angular/common": "7.1.0",
    "@angular/core": "7.1.0",
    "@angular/forms": "7.1.0",
    "@angular/http": "7.1.0",
    "@angular/platform-browser": "7.1.0",
    "@angular/platform-browser-dynamic": "7.1.0",
    "@angular/router": "7.1.0",
    "@ionic-native/app-version": "4.17.0",
    "@ionic-native/camera": "4.17.0",
    "@ionic-native/core": "4.17.0",
    "@ionic-native/device": "4.17.0",
    "@ionic-native/fcm": "^4.17.0",
    "@ionic-native/file": "^4.7.0",
    "@ionic-native/firebase": "^4.17.0",
    "@ionic-native/google-analytics": "4.17.0",
    "@ionic-native/google-plus": "4.17.0",
    "@ionic-native/image-resizer": "4.17.0",
    "@ionic-native/local-notifications": "^4.17.0",
    "@ionic-native/native-storage": "^4.17.0",
    "@ionic-native/splash-screen": "~4.17.0",
    "@ionic-native/sqlite": "^4.17.0",
    "@ionic-native/sqlite-porter": "^4.17.0",
    "@ionic-native/status-bar": "4.17.0",
    "@ionic-native/unique-device-id": "^4.17.0",
    "@ionic-native/youtube-video-player": "4.17.0",
    "@ionic/pro": "2.0.3",
    "@ionic/storage": "2.1.3",
    "@ngx-translate/core": "10.0.2",
    "@ngx-translate/http-loader": "^3.0.1",
    "@types/google-maps": "^3.2.0",
    "angular2-uuid": "^1.1.1",
    "angularfire2": "^5.1.0",
    "cordova": "^8.0.0",
    "cordova-android": "7.1.2",
    "cordova-android-support-gradle-release": "^1.4.4",
    "cordova-browser": "5.0.3",
    "cordova-ios": "4.5.5",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-ionic-webview": "2.2.5",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-geolocation": "^2.4.3",
    "cordova-plugin-googleplus": "~5.3.2",
    "cordova-plugin-local-notification": "^0.9.0-beta.2",
    "cordova-plugin-media": "^5.0.2",
    "cordova-plugin-nativestorage": "^2.3.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-uniquedeviceid": "^1.3.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-youtube-video-player": "^2.0.0",
    "cordova-sqlite-storage": "^2.5.1",
    "firebase": "^5.5.9",
    "global": "^4.3.2",
    "imagemin": "^5.3.1",
    "info.protonet.imageresizer": "^0.1.1",
    "ionic": "^3.20.1",
    "ionic-angular": "3.9.2",
    "ionic-tooltips": "^2.1.1",
    "ionicons": "4.2.6",
    "jquery": "^3.3.1",
    "local-storage": "^1.4.2",
    "moment": "^1.7.2",
    "ng-lottie": "^0.3.2",
    "ng2-reactive-forms-validators": "^1.1.0",
    "promise-polyfill": "8.1.0",
    "q": "^1.5.1",
    "run": "1.4.0",
    "rxjs": "^6.3.2",
    "rxjs-compat": "^6.3.2",
    "sqlite3": "^4.0.0",
    "sw-toolbox": "3.6.0",
    "typeorm": "0.2.8",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "7.0.6",
    "@angular/compiler": "7.1.0",
    "@angular/compiler-cli": "7.1.0",
    "@ionic/app-scripts": "3.2.0",
    "@types/google.analytics": "0.0.39",
    "@types/googlemaps": "^3.30.11",
    "@types/node": "^10.5.4",
    "sql.js": "^0.5.0",
    "ts-node": "7.0.0",
    "typescript": "3.1.6"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-device",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-splashscreen"
  ],
  "cordovaPlatforms": [],
  "cordova": {
    "plugins": {
      "cordova-sqlite-storage": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": " "
      },
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "info.protonet.imageresizer": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-googleplus": {
        "REVERSED_CLIENT_ID": "com.googleusercontent.apps.781145103219-a87b3bd7d7858i8lrr2531nm8ml2bj6c",
        "WEB_APPLICATION_CLIENT_ID": "781145103219-vn75hrm8tv0b54hkck4dokv5nnr0pvao.apps.ioniusercontent.com"
      },
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-uniquedeviceid": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-nativestorage": {},
      "cordova-plugin-file": {},
      "cordova-plugin-youtube-video-player": {},
      "cordova-plugin-local-notification": {},
      "cordova-android-support-gradle-release": {
        "ANDROID_SUPPORT_VERSION": "27.+"
      }
    },
    "platforms": [
      "browser",
      "ios",
      "android"
    ]
  }
}

Update: tsconfig.json

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "lib": [
      "dom",
      "es2017"
    ],
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "ES2017",
    "types" : ["node"],
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/**/*.spec.ts",
    "src/**/__tests__/*.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}
1
Probably the runtime does not have native support for async/await what target do you specify in your tsconfig.json?Titian Cernicova-Dragomir
@TitianCernicova-Dragomir I've added the tsconfig.ts to the issue. ES2017 is present in tsconfig.jsonexequielc

1 Answers

2
votes

Two things to check...

ECMAScript Version

You can target different ECMAScript versions with the TypeScript compiler, so make sure you are targeting the version you are using at runtime. i.e. in your tsconfig.json file:

"target": "ES5"

This will then transform your async/await into a format usable in that runtime.

JavaScript

If you have done the above and still have a problem, it is commonly caused by loading the TypeScript file .ts by accident at runtime, rather than the JavaScript .js file.