White screen after splashscreen, Ionic2, android device

后端 未结 4 2012
慢半拍i
慢半拍i 2020-12-05 17:31

I am currently developing Ionic2 app. I face a problem that after Splash screen, there is a white screen for 6-7 seconds, before app home screen.

I tried some googli

相关标签:
4条回答
  • 2020-12-05 18:13

    Add the --prod flag during any of the following CLI commands:

    // If iOS
    ionic emulate ios --prod
    ionic build ios --prod
    ionic run ios --prod
    
    
    // If Android
    ionic emulate android --prod
    ionic build android --prod
    ionic run android --prod
    

    More info of build (prepare + compile) an Ionic project for a given platform https://ionicframework.com/docs/cli/cordova/build/

    0 讨论(0)
  • 2020-12-05 18:20

    Updating Ionic project and change some preferences did the trick for me.

    Here the changelog and infos.

    1 - Update to the latest version of the Ionic CLI, Cordova and Typescript:

    npm uninstall -g ionic cordova typescript
    npm install -g ionic cordova typescript
    

    2 - Update your package.json to match the following dependencies, remove existing node_modules directory, and then run npm install:

      "scripts": {
        "build": "ionic-app-scripts build",
        "clean": "ionic-app-scripts clean",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
      },
      "dependencies": {
        "@angular/common": "4.0.2",
        "@angular/compiler": "4.0.2",
        "@angular/compiler-cli": "4.0.2",
        "@angular/core": "4.0.2",
        "@angular/forms": "4.0.2",
        "@angular/http": "4.0.2",
        "@angular/platform-browser": "4.0.2",
        "@angular/platform-browser-dynamic": "4.0.2",
        "@ionic-native/core": "3.6.1",
        "@ionic-native/in-app-browser": "3.6.1",
        "@ionic-native/splash-screen": "3.6.1",
        "@ionic-native/status-bar": "3.6.1",
        "@ionic/storage": "2.0.1",
        "ionic-angular": "3.1.1",
        "ionicons": "3.0.0",
        "rxjs": "5.1.1",
        "sw-toolbox": "3.4.0",
        "zone.js": "0.8.9"
      },
      "devDependencies": {
        "@ionic/app-scripts": "1.3.6",
        "typescript": "2.3.2"
      }
    

    3 - Update your config.xlm with these preferences (live review is ok):

      <preference name="loadUrlTimeoutValue" value="700000"/>
      <preference name="webviewbounce" value="false"/>
      <preference name="UIWebViewBounce" value="false"/>
      <preference name="DisallowOverscroll" value="true"/>
      <preference name="android-minSdkVersion" value="16"/>
      <preference name="BackupWebStorage" value="none"/>
      <preference name="StatusBarStyle" value="default"/>
      <preference name="SplashScreen" value="screen"/>
      <preference name="orientation" value="default"/>
      <preference name="SplashMaintainAspectRatio" value="true"/>
      <preference name="FadeSplashScreenDuration" value="300"/>
      <preference name="ShowSplashScreenSpinner" value="false"/>
      <preference name="AutoHideSplashScreen" value="false"/>
      <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine"/>
      <preference name="SplashScreenDelay" value="3000"/>
    

    4 - Then I have copy/pasted some code that had been modified recently from here into my project (Ionic 2 demo and up to date app - Check the Github).

    Now the application starts successfully without long splashscreen.

    ps:

    • livereview: ionic run android -l
    • production: ionic run android --prod --release
    • Remember that you have to hide manually the splashscreen (like @Markus Wagner said) in your app.component.ts: this.platform.ready().then(() => { Splashscreen.hide(); });

    EDIT: Update to Ionic v3.1.1 (2017-04-28)

    0 讨论(0)
  • 2020-12-05 18:26

    I’ve solved that issue by setting the correct parameters on config.xml

     <preference name="AutoHideSplashScreen" value="false" />
     <preference name="SplashScreenDelay" value="10000" />
     <preference name="FadeSplashScreenDuration" value="1000" />
     <preference name="SplashScreen" value="screen" />
     <preference name="ShowSplashScreen" value="true" />
     <preference name="ShowSplashScreenSpinner" value="false" />
     <preference name="SplashShowOnlyFirstTime" value="false" />
     <preference name="FadeSplashScreen" value="true" />
    

    Then, on my platform.ready() instruction all I do is Splashscreen.hide();

    0 讨论(0)
  • 2020-12-05 18:31

    By default, the splash screen is hidden after 3 seconds (see https://github.com/apache/cordova-plugin-splashscreen#configxml). But it could be that at this moment your app is not ready.

    Therefore I add always the following preference to my config.xml:

    <preference name="AutoHideSplashScreen" value="false"/>
    

    Instead, I hide it manually, as soon as the app is ready:

    this.platform.ready().then(() => {
        Splashscreen.hide();
    });
    

    This is working on iOS as well as on Android.

    0 讨论(0)
提交回复
热议问题