首页 > 解决方案 > Ionic 3 - 应用程序在初始屏幕上挂起(可能与 Ionic Deploy 有关)

问题描述

我正在对我的 ionic 应用程序进行一些更改,它突然决定挂在启动屏幕上并且根本不加载应用程序。我在我使用的模拟器上附加了一个调试器,这是生成的错误消息:

Unhandled Promise rejection: Cannot read property 'getServerBasePath' of undefined ; Zone: <root> ; Task: Promise.then ; Value:
polyfills.js:3
TypeError: Cannot read property 'getServerBasePath' of undefined
polyfills.js:3
TypeError: Cannot read property 'getServerBasePath' of undefined
    at IonicDeployImpl.<anonymous> (file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:575:46)
    at step (file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:37:23)
    at Object.next (file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:18:53)
    at file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:12:71
    at new t (file:///android_asset/www/build/polyfills.js:3:21506)
    at __awaiter (file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:8:12)
    at file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:572:87
    at new t (file:///android_asset/www/build/polyfills.js:3:21506)
    at IonicDeployImpl.<anonymous> (file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:572:39)
    at step (file:///android_asset/www/plugins/cordova-plugin-ionic/dist/common.js:37:23)

几乎就好像离子实时部署以某种方式失败了,但我不确定为什么 - 我的 package.json 在下面列出。

我在官方 ionic 问题跟踪论坛上发现了一些看起来相似的问题,但在大多数情况下,我使用的 cordova-plugin-ionic 版本比发生这些问题的版本大:

第 107 期 第 109 期

这个问题(Issue 116)看起来最接近我所经历的,但我认为它仍然不一样。

任何帮助将不胜感激,因为我觉得我已经用尽了我能想到的一切来解决这个问题。

包.json

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "config": {
    "ionic_bundler": "webpack",
    "ionic_source_map": "source-map",
    "ionic_copy": "./config/copy.config.js"
  },
  "dependencies": {
    "@angular/animations": "5.0.3",
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@auth0/angular-jwt": "^1.2.0",
    "@ionic-native/admob-free": "^4.8.0",
    "@ionic-native/base64": "^4.8.0",
    "@ionic-native/camera": "^4.8.0",
    "@ionic-native/core": "^4.8.0",
    "@ionic-native/crop": "^4.8.0",
    "@ionic-native/diagnostic": "^4.8.0",
    "@ionic-native/splash-screen": "^4.8.0",
    "@ionic-native/status-bar": "^4.8.0",
    "@ionic/storage": "2.1.3",
    "angular-calendar": "0.24.1",
    "angular-jwt": "0.1.9",
    "com-badrit-base64": "^0.2.0",
    "cordova-admob-sdk": "^0.17.0",
    "cordova-android": "~6.3.0",
    "cordova-ios": "^4.3.1",
    "cordova-plugin-admob-free": "^0.17.2",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-console": "^1.0.5",
    "cordova-plugin-crop": "^0.4.0",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-ionic": "^5.2.4",
    "cordova-plugin-ionic-webview": "^2.1.4",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-promise-polyfill": "0.0.2",
    "cordova.plugins.diagnostic": "^4.0.8",
    "cropperjs": "^1.4.0",
    "exif-js": "^2.3.0",
    "font-awesome": "^4.7.0",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "jimp": "^0.2.27",
    "moment": "^2.18.1",
    "rxjs": "^5.5.2",
    "sw-toolbox": "3.6.0",
    "ts-exif-parser": "^0.1.23",
    "web-photo-filter": "^1.1.1",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.1.7",
    "@ionic/pro": "^2.0.3",
    "@types/node": "^10.3.6",
    "typescript": "~2.4.2"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "SafteyTicketApp: An Ionic project",
  "cordova": {
    "platforms": [
      "ios",
      "android"
    ],
    "plugins": {
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-crop": {},
      "ionic-plugin-keyboard": {},
      "cordova.plugins.diagnostic": {},
      "cordova-plugin-admob-free": {},
      "com-badrit-base64": {},
      "cordova-plugin-camera": {
        "CAMERA_USAGE_DESCRIPTION": "To track and record safety tickets.",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": "To track and record safety tickets."
      },
      "cordova-plugin-ionic": {
        "APP_ID": "APPID",
        "CHANNEL_NAME": "Production",
        "UPDATE_METHOD": "auto",
        "UPDATE_API": "https://api.ionicjs.com",
        "MAX_STORE": "2",
        "MIN_BACKGROUND_DURATION": "30"
      }
    }
  }
}

标签: cordovaionic-frameworkionic3

解决方案


我尝试重现您的环境并且没有失败。

我看到问题出在

Ionic.WebView.getServerBasePath(resolve);

通过附加 safari 调试,您可以访问 Ionic 全局变量吗?似乎未加载此变量。

我可以看到你没有安装 webview 插件,尝试安装它:

cordova plugin add cordova-plugin-ionic-webview

尝试修复它的其他方法是删除node_modules插件平台并安装所有。或者启动一个新项目,查看新闻包/插件的版本和版本。


推荐阅读