在Android 6或7和Android Oreo(8.1)上运行应用程序时出现此错误
这是从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
复制步骤
使用命令-> ionic cordova运行android
在设备android上运行项目[Android APi 23至27遇到相同问题]相关代码
[588]行是这个-> 异步revisa_sincro(){<..... code ....>}
预期行为
因此,真正的问题是此[async]关键字使应用程序停止运行并向我显示白色屏幕, 控制台未捕获的SyntaxError上的此错误。 如果我删除所有异步代码,则应用运行正常。但我真的需要这个异步!!!
其他上下文 我怎么解决不了这个问题,有什么解决方法吗?
离子信息
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 (cordova-lib@8.1.1)
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"
]
}
}
更新: 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
}
}
答案 0 :(得分:2)
要检查的两件事...
您可以使用TypeScript编译器定位不同的ECMAScript版本,因此请确保定位的是运行时使用的版本。即在您的tsconfig.json文件中:
"target": "ES5"
这会将您的异步/等待转换为在该运行时中可用的格式。
如果您已完成上述操作,但仍然有问题,通常是由于在运行时意外加载TypeScript文件.ts
而非JavaScript .js
文件引起的。