【问题标题】:White screen after splash screen in Ionic2Ionic2中启动画面后的白屏
【发布时间】:2019-11-04 14:44:36
【问题描述】:

当我将我的应用程序转换为 *.apk 时执行启动画面后出现白屏的小问题,它需要 20 到 25 秒然后我的应用程序运行正常。

那么有什么设置或者代码或者工具可以解决这个问题吗?

备注

~ 应用大小:19mb

~ 在三星 Galaxy J7 2016 - android 7.0 上测试

~ 我用这种方式将我的应用程序转换为 apk :How to generate ionic apk or ios without extra applications?

【问题讨论】:

    标签: ionic2 wait splash-screen


    【解决方案1】:

    通过使用

    离子构建 android --prod

    启动时间将减少到大约 5 秒,并且对于白屏,

    问题是闪屏自动隐藏,所以禁用闪屏自动隐藏和从

    app.component.ts

    我手动隐藏了它。

    config.xml

    <preference name="SplashMaintainAspectRatio" value="true"/>
     <preference name="SplashScreen" value="screen"/>
     <preference name="SplashScreenDelay" value="30000"/>
     <preference name="AutoHideSplashScreen" value="false"/>
     <preference name="SplashShowOnlyFirstTime" value="false"/>
     <preference name="FadeSplashScreen" value="false"/>
    

    app.component.ts

    import { Component } from '@angular/core';
    import { Platform } from 'ionic-angular';
    import { StatusBar } from '@ionic-native/status-bar';
    import { SplashScreen } from '@ionic-native/splash-screen';
    @Component({
     templateUrl: 'app.html'
    })
    export class MyApp {
     rootPage:string = 'HomePage';
     constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
     platform.ready().then(() => {
     // Okay, so the platform is ready and our plugins are available.
     // Here you can do any higher level native things you might need.
     statusBar.styleDefault();
     splashScreen.hide();
     });
     }
    }
    

    【讨论】:

    • 那么对于所有由 ionic 开发的应用程序来说,我可以理解在启动我的应用程序之前等待 20 秒是正常的吗?因为我用尽一切办法来解决这个问题,但没有什么能让我在等待不到 20 秒的情况下就开始使用我的应用程序
    • 使用生产版本,它使启动时间更快 ionic build android --prod
    【解决方案2】:

    要构建您的 apk 文件,只需使用:

    ionic build android 
    (or) ionic cordova build android (In ionic3)
    

    要在设备中运行您的应用,只需使用:

    ionic run android (ionic cordova run android)
    (or) ionic run android --livereload (for live reload) (ionic cordova run android --livereload)
    

    查看更多关于ioni cli
    20s 启动应用程序是正常调试模式。运行 ionic build--prod 变量,您会看到您的应用启动速度更快,但构建需要更多时间。

    【讨论】:

    • 那么对于所有由 ionic 开发的应用程序来说,我可以理解在启动我的应用程序之前等待 20 秒是正常的吗?因为我用尽一切办法来解决这个问题,但没有什么能让我在等待不到 20 秒的情况下就开始使用我的应用程序
    • 花药点,我检查了你的命令,但它显示错误.. 可能我应该安装一些添加,如 android studio 或其他东西
    • 是的。对于所有应用程序都是正常的。看到这个guide 来构建你的应用程序
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 1970-01-01
    相关资源
    最近更新 更多