在启动屏幕后,Ionic 3需要花费大量时间才能进入应用程序

时间:2018-08-24 09:51:14

标签: angular ionic-framework ionic3

该应用程序运行正常,但进入首页大约需要10 sc。 我认为问题在于我无法运行ionic cordova build ios/android build --prod来最小化代码或捆绑包

它给了我这个错误

Error: Metadata version mismatch for module /Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@ionic-native/file/index.d.ts, found version 4, expected 3
    at StaticSymbolResolver.getModuleMetadata (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:25616:34)
    at StaticSymbolResolver._createSymbolsOf (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:25404:46)
    at StaticSymbolResolver.getSymbolsOf (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:25385:14)
    at /Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:24241:30
    at Array.forEach (<anonymous>)
    at extractProgramSymbols (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:24240:79)
    at AotCompiler.analyzeModulesAsync (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:23796:47)
    at CodeGenerator.codegen (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler-cli/src/codegen.js:32:14)
    at Function.NgTools_InternalApi_NG_2.codeGen (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@angular/compiler-cli/src/ngtools_api.js:73:30)
    at Object.doCodegen (/Users/quanticosolutions/Desktop/myseg/mobile/node_modules/@ionic/app-scripts/dist/aot/codegen.js:6:51)

但是如果我做离子Cordova来构建ios / android或运行正常,但是要花费很多时间...

我的离子信息

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.0.0-201710070411
    Cordova Platforms  : android 6.4.0 browser 5.0.3 ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node  : v8.11.1
    npm   : 5.6.0
    OS    : macOS High Sierra
    Xcode : Xcode 9.4.1 Build version 9F2000

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

我的package.json

{
  "name": "mypp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "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"
  },
  "dependencies": {
    "@angular/animations": "^4.4.6",
    "@angular/cdk": "^2.0.0-beta.12",
    "@angular/common": "^4.4.6",
    "@angular/compiler": "^4.4.6",
    "@angular/compiler-cli": "^4.4.6",
    "@angular/core": "^4.4.6",
    "@angular/forms": "^4.4.6",
    "@angular/http": "^4.4.6",
    "@angular/material": "^2.0.0-beta.12",
    "@angular/platform-browser": "^4.4.6",
    "@angular/platform-browser-dynamic": "^4.4.6",
    "@ionic-native/base64-to-gallery": "^4.7.0",
    "@ionic-native/camera": "^4.7.0",
    "@ionic-native/core": "^4.7.0",
    "@ionic-native/crop": "^4.5.2",
    "@ionic-native/device": "^4.7.0",
    "@ionic-native/document-viewer": "^4.7.0",
    "@ionic-native/email-composer": "^4.7.0",
    "@ionic-native/file": "^4.11.0",
    "@ionic-native/file-opener": "^4.7.0",
    "@ionic-native/geolocation": "^4.7.0",
    "@ionic-native/google-maps": "^4.7.0",
    "@ionic-native/image-picker": "^4.5.3",
    "@ionic-native/keyboard": "^4.10.0",
    "@ionic-native/market": "^4.7.0",
    "@ionic-native/native-audio": "^4.7.0",
    "@ionic-native/native-geocoder": "^4.7.0",
    "@ionic-native/network": "^4.7.0",
    "@ionic-native/onesignal": "^4.8.0",
    "@ionic-native/phonegap-local-notification": "^4.8.0",
    "@ionic-native/screen-orientation": "^4.7.0",
    "@ionic-native/sms": "^4.7.0",
    "@ionic-native/splash-screen": "^4.7.0",
    "@ionic-native/sqlite": "^4.7.0",
    "@ionic-native/status-bar": "^4.7.0",
    "@ionic/storage": "^2.0.1",
    "@toverux/ngx-sweetalert2": "^4.0.0",
    "@types/jspdf": "^1.1.31",
    "android": "0.0.8",
    "angular2-jwt": "^0.2.3",
    "angular2-jwt-refresh": "^0.1.0",
    "angular2-signature-pad": "^1.0.2",
    "angular2-signaturepad": "^2.6.1",
    "angularfire2": "^5.0.0-rc.3",
    "cordova": "^8.0.0",
    "cordova-android": "^6.4.0",
    "cordova-android-support-gradle-release": "^1.4.2",
    "cordova-base64-to-gallery": "^4.1.3",
    "cordova-browser": "5.0.3",
    "cordova-ios": "4.5.4",
    "cordova-plugin-add-swift-support": "^1.7.2",
    "cordova-plugin-camera": "^2.4.1",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-crop": "^0.4.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-document-viewer": "^0.9.9",
    "cordova-plugin-email-composer": "^0.8.15",
    "cordova-plugin-file": "^4.3.3",
    "cordova-plugin-file-opener2": "^2.0.19",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-geolocation": "^2.4.3",
    "cordova-plugin-googlemaps": "^2.2.9",
    "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git#2.6.0",
    "cordova-plugin-market": "^1.2.0",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-nativegeocoder": "^3.1.1",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-photo-library": "^2.1.1",
    "cordova-plugin-screen-orientation": "^3.0.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-webserver": "git+https://github.com/bykof/cordova-plugin-webserver.git",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-plugin-wkwebview": "^0.6.10",
    "cordova-sms-plugin": "^0.1.11",
    "cordova-sqlite-storage": "^2.3.1",
    "es6-promise-plugin": "^4.2.2",
    "firebase": "^4.8.0",
    "font-awesome": "^4.7.0",
    "ion-multi-picker": "^2.1.2",
    "ionic-angular": "^3.9.2",
    "ionic-gallery-modal": "^0.2.7",
    "ionic-image-loader": "^5.0.5",
    "ionic-img-viewer": "^2.9.0",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "jspdf": "^1.3.5",
    "moment": "^2.20.1",
    "ng-lottie": "^0.3.1",
    "ng2-pdf-viewer": "^2.0.3",
    "onesignal-cordova-plugin": "^2.4.1",
    "pdfmake": "^0.1.35",
    "phonegap-plugin-local-notification": "^1.0.1",
    "promise-polyfill": "^6.1.0",
    "rxjs": "5.4.0",
    "signature_pad": "^2.3.2",
    "sw-toolbox": "3.6.0",
    "sweetalert2": "^7.22.2",
    "twilio": "^3.7.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.0.0-201710070411",
    "@types/signature_pad": "0.0.30",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project",
  "cordova": {
    "platforms": [
      "browser",
      "ios",
      "android"
    ],
    "plugins": {
      "ionic-plugin-keyboard": {},
      "cordova-sms-plugin": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-googlemaps": {
        "API_KEY_FOR_ANDROID": "xxx",
        "API_KEY_FOR_IOS": "xxx",
        "LOCATION_WHEN_IN_USE_DESCRIPTION": "Show your location on the map",
        "LOCATION_ALWAYS_USAGE_DESCRIPTION": "Trace your location on the map"
      },
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": " "
      },
      "cordova-plugin-camera": {
        "CAMERA_USAGE_DESCRIPTION": " ",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": " "
      },
      "cordova-plugin-file": {},
      "cordova-plugin-file-opener2": {},
      "cordova-plugin-email-composer": {},
      "cordova-plugin-document-viewer": {},
      "cordova-plugin-device": {},
      "cordova-plugin-market": {},
      "cordova-plugin-add-swift-support": {},
      "cordova-plugin-screen-orientation": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-sqlite-storage": {},
      "cordova-plugin-compat": {},
      "cordova-plugin-nativegeocoder": {
        "LOCATION_WHEN_IN_USE_DESCRIPTION": "Use geocoder service"
      },
      "cordova-plugin-webserver": {},
      "cordova-plugin-crop": {},
      "cordova-android-support-gradle-release": {
        "ANDROID_SUPPORT_VERSION": "27.+"
      },
      "cordova-base64-to-gallery": {},
      "cordova-plugin-nativeaudio": {},
      "cordova-plugin-network-information": {},
      "phonegap-plugin-local-notification": {},
      "onesignal-cordova-plugin": {}
    }
  }
}

我的config.xml用于启动画面

  <preference name="AutoHideSplashScreen" value="false" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="ShowSplashScreenSpinner" value="true" />
    <preference name="FadeSplashScreen" value="true" />

app.component

import {Component} from '@angular/core';
import {Platform} from 'ionic-angular';
import {StatusBar, Splashscreen} from 'ionic-native';
import {HomePage} from './pages/home/home';

@Component({
  template: '<ion-nav [root]="rootPage"></ion-nav>'
})
export class MyApp {
  rootPage: any = HomePage;

  constructor(platform: Platform) {
    platform.ready().then(() => {
      Splashscreen.hide()
      StatusBar.styleDefault();
    });
  }
}

1 个答案:

答案 0 :(得分:0)

通过将离子本机文件插件降级到以前的版本来解决问题

npm install --save @ionic-native/file@4.3.3