我最近将离子更新到版本3.9.2但运行时发生错误"离子cordova运行android --device"或者当我使用Ionic DevApp时。
当我在我的智能手机上使用Android 7.0执行命令时,所有功能都完美无缺,但在使用android 4.4.4在我的平板电脑上运行时出现错误
跑步"离子医生检查"没有发现问题。
错误是"意外的令牌<",没有其他细节。
这是我的package.json
"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"
},
"dependencies": {
"@angular/animations": "5.0.0",
"@angular/common": "5.0.0",
"@angular/compiler": "5.0.0",
"@angular/compiler-cli": "5.0.0",
"@angular/core": "5.0.0",
"@angular/forms": "5.0.0",
"@angular/http": "5.0.0",
"@angular/platform-browser": "5.0.0",
"@angular/platform-browser-dynamic": "5.0.0",
"@ionic-native/core": "4.4.0",
"@ionic-native/email-composer": "4.4.0",
"@ionic-native/facebook": "4.4.0",
"@ionic-native/google-plus": "4.4.0",
"@ionic-native/http": "4.4.0",
"@ionic-native/launch-navigator": "4.4.0",
"@ionic-native/onesignal": "4.4.0",
"@ionic-native/splash-screen": "4.4.0",
"@ionic-native/status-bar": "4.4.0",
"@ionic-native/twitter-connect": "4.4.0",
"@ionic/storage": "2.1.3",
"@ngx-translate/core": "^8.0.0",
"@ngx-translate/http-loader": "^2.0.0",
"android-versions": "^1.2.1",
"cordova-android": "^6.2.3",
"cordova-ios": "^4.5.1",
"cordova-plugin-actionsheet": "^2.3.3",
"cordova-plugin-advanced-http": "^1.6.1",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-dialogs": "^1.3.3",
"cordova-plugin-email-composer": "^0.8.11",
"cordova-plugin-facebook4": "^1.9.1",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-googleplus": "^5.1.1",
"cordova-plugin-ionic-webview": "^1.1.14",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "git+https://github.com/apache/cordova-plugin-statusbar.git",
"cordova-plugin-whitelist": "^1.3.1",
"cordova-sqlite-storage": "^2.0.4",
"ionic-angular": "^3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"onesignal-cordova-plugin": "^2.2.2",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"twitter-connect-plugin": "git+https://github.com/chroa/twitter-connect-plugin.git",
"uk.co.workingedge.phonegap.plugin.launchnavigator": "^4.0.5",
"web-animations-js": "^2.3.1",
"zone.js": "0.8.18"
},
"devDependencies": {
"@ionic/app-scripts": "^3.1.0",
"typescript": "2.4.2"
},
"description": "An Ionic project",
"cordova": {
"platforms": [
"android",
"ios"
],
"plugins": {
"cordova-plugin-device": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"uk.co.workingedge.phonegap.plugin.launchnavigator": {},
"cordova-plugin-advanced-http": {},
"cordova-sqlite-storage": {},
"onesignal-cordova-plugin": {},
"twitter-connect-plugin": {
"FABRIC_KEY": "xxxxxxxxxxxxxxxxxxx",
"TWITTER_KEY": "xxxxxxxxxxx",
"TWITTER_SECRET": "xxxxxxxxxxxxxx"
},
"cordova-plugin-email-composer": {},
"cordova-plugin-facebook4": {
"APP_ID": "xxxxxxxxxxxxxxxx",
"APP_NAME": "xxxxxxxxxx"
},
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "xxxxxxxxxx"
}
}
}
这是我的系统信息
Ionic App Scripts: 3.1.0
Angular Core: 5.0.0
Angular Compiler CLI: 5.0.0
Node: 6.11.4
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:56.0) Gecko/20100101 Firefox/56.0
这是我的config.xml
<widget id="XXXXX" version="14.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>xxxxxxx</name>
<description>xxxxx</description>
<author email="xxxxxxx" href="xxxxxxxxxxxx">xxxxxxxxx</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="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="orientation" value="portrait" />
<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>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<preference name="deployment-target" value="7.0" />
<icon height="57" src="resources/ios/icon/icon.png" width="57" />
<icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
<icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
<icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
<icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
<icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
<icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
<icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
<icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
<icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
<icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
<icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
<icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
<icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
<icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
<icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
<icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
<icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
<splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
<splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
<splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
<splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
<splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
<splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
<splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
<splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
<splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
<splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>
<allow-navigation href="http://192.168.1.6:8100" />
<engine name="android" spec="^6.2.3" />
<engine name="ios" spec="^4.5.1" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.14" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="git+https://github.com/apache/cordova-plugin-statusbar.git" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
<plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" spec="^4.0.5" />
<plugin name="cordova-plugin-advanced-http" spec="^1.6.1" />
<plugin name="cordova-sqlite-storage" spec="^2.0.4" />
<plugin name="onesignal-cordova-plugin" spec="^2.2.2" />
<plugin name="twitter-connect-plugin" spec="git+https://github.com/chroa/twitter-connect-plugin.git">
<variable name="FABRIC_KEY" value="xxxxxxxxx" />
<variable name="TWITTER_KEY" value="xxxxxxxx" />
<variable name="TWITTER_SECRET" value="xxxxxxxxxxxxx" />
</plugin>
<plugin name="cordova-plugin-email-composer" spec="^0.8.11" />
<plugin name="cordova-plugin-facebook4" spec="^1.9.1">
<variable name="APP_ID" value="xxxxxxxxxxx" />
<variable name="APP_NAME" value="xxxxxxxxxxx" />
</plugin>
<plugin name="cordova-plugin-googleplus" spec="^5.1.1">
<variable name="REVERSED_CLIENT_ID" value="xxxxxxxxxxxxxxxxxxx" />
</plugin>
</widget>
如果我在控制台中检查我的平板电脑设备,我看到该错误引用了main.js中的一行这是行
MyApp = __decorate([
Object(__WEBPACK_IMPORTED_MODULE_0__angular_core__["m" /* Component */])({template:/*ion-inline-start:"/path/src/app/app.html"*/`<ion-menu [content]="content" persistent>\n\n <ion-content padding-top class="menu-content">\n\n <button ion-button icon-only menuToggle float-left clear color="white">\n <ion-icon name="close"></ion-icon>\n </button>\n <div class="imglogo" text-center no-padding>\n <img src="assets/img/icona-app-210gr.png">\n </div>\n <ion-list class="menulist" no-lines inset>\n <button ion-item *ngFor="let p of pages" (click)="openPage(p)" detail-none text-center>\n <strong class="bebas" translate>{{p.title}}</strong>\n </button>\n\n <button ion-item (click)="flagTapped(\'it\')" detail-none text-center>\n <strong class="bebas" translate>{{\'LANG_ITALIAN\'}}</strong>\n </button>\n <button ion-item (click)="flagTapped(\'en\')" detail-none text-center>\n <strong class="bebas" translate>{{\'LANG_ENGLISH\'}}</strong>\n </button>\n\n <a ion-item href="xxxxxxxxxxxx" detail-none text-center>\n <strong class="bebas" translate>{{\'LANG_PRIVACY\'}}</strong>\n </a>\n </ion-list>\n <button ion-button menuToggle clear color="white" float-right icon-end (click)="logout()">\n <span translate>{{\'LANG_LOGOUT\'}}</span>\n <ion-icon name="log-out"></ion-icon>\n </button>\n </ion-content>\n\n</ion-menu>\n\n<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>\n`/*ion-inline-end:"/path/src/app/app.html"*/
})
我没有记错。在手机中一切都还可以,平板电脑没有。这是一个离子错误还是我的错误?
谢谢
更新13/11/2017 新的调查:问题是设备与Android版本&lt; = 4.4.4智能手机和平板电脑。 但Ionic 3本身不支持android 4.4 +?
更新13/11/2017#2 问题解决了。我已经安装了crosswalk插件而不是所有的工作
答案 0 :(得分:0)
当我在我的智能手机Huawaei上使用android 7.0执行命令时 一切都很完美,但是在我的平板电脑上运行时我会收到错误 用android 4.4.4
错误是“意外的令牌&lt;”,没有其他细节。
我刚刚遇到了一个非常类似的问题,因为在一个特定的设备上(恰好是Android 4.4.4),浏览器webview太老了,无法理解编译的JavaScript。
这将导致可怕的“白屏死机”,并且调试会特别痛苦。
一个简单的解决方案就是使用人行横道:
ionic cordova plugin add cordova-plugin-crosswalk-webview
重建,问题应该消失。
虽然这会使你的APK膨胀,增加一些额外的25Mb,但我建议在支持相当旧的设备时总是使用人行横道。
即使它在没有这些功能的情况下也能正常工作,通常会有一些微妙的事情,比如动画输入等等,会导致用户体验不佳。
答案 1 :(得分:0)
android 7.0支持es6(es2015)和android 4.4.4可能没有 - 我有一个类似的问题,因为autocomplete错误导入了离子角度es2015中的一个类
我从' ionic-angular / es2015 '导入{Slides}而不是从' ionic-angular '导入{Slides};
答案 2 :(得分:0)
检查捆绑文件是否确实存在。 通常会发生此问题,因为浏览器找不到捆绑包JS文件。此“ <”令牌仅是404响应服务器的html开头标记。 应用程序希望读取JS而不是HTML