V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
qweweretrt515
V2EX  ›  问与答

ionic 开发的 app,启动需要 10 秒,怎么优化

  •  
  •   qweweretrt515 · 2016-11-15 16:57:16 +08:00 · 4998 次点击
    这是一个创建于 2724 天前的主题,其中的信息可能已经有所发展或是发生改变。

    ionic platform add android cordova plugin add cordova-plugin-crosswalk-webview ionic build android

    然后把 android-armv7-debug.apk 拷贝到手机上 安装以后 点击运行,要 10 秒才看的到 app 界面

    第 1 条附言  ·  2016-11-15 22:51:53 +08:00
    android4.4.4 三星手机
    第 2 条附言  ·  2016-11-16 13:05:24 +08:00
    我的配置文件如下:

    。。。。。。

    <platform name="ios">
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
    </platform>
    <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="SplashScreenDelay" value="0"/>
    <preference name="FadeSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="0"/>
    <preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
    <preference name="SplashScreen" value="screen"/>
    <feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar"/>
    </feature>
    <plugin name="cordova-plugin-device" spec="~1.1.3"/>
    <plugin name="cordova-plugin-console" spec="~1.0.4"/>
    <plugin name="cordova-plugin-whitelist" spec="~1.3.0"/>
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.0"/>
    <plugin name="cordova-plugin-statusbar" spec="~2.2.0"/>
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
    </widget>
    第 3 条附言  ·  2016-11-16 13:28:41 +08:00
    这是我目前 的 配置文件 http://sharetext.cn/1738

    点击运行,瞬间就可以看到 画面,但是接下来就一直黑屏了 8 秒,才进入了界面

    求助大神,还可以如何优化
    第 4 条附言  ·  2016-11-16 16:11:56 +08:00
    刚才我发现了官方提供的 demo ,打包后,打开 还是延迟了 10 秒, 由此推测,可能代码和配置没有问题, 有可能是我机器的环境 有问题,我先把其他地方搞定,回头换个环境打包 ,在看看,
    11 条回复    2016-11-16 17:11:14 +08:00
    lokk666
        1
    lokk666  
       2016-11-15 20:49:38 +08:00   ❤️ 1
    你的启动页时间太长了,在 config.xml 里面把 SplashScreenDelay 改小点。希望能帮到你 XD
    qweweretrt515
        2
    qweweretrt515  
    OP
       2016-11-15 22:37:54 +08:00
    @lokk666 你好,这个值 我写的是 0 ,还有其他地方能优化吗
    murmur
        3
    murmur  
       2016-11-15 22:39:37 +08:00   ❤️ 1
    你是安卓几呢 ionic 最好要 android4.4 低配真无解
    qweweretrt515
        4
    qweweretrt515  
    OP
       2016-11-15 22:51:44 +08:00
    @murmur android4.4.4 三星手机 因为后面也要考虑低配手机的用户体验,所以有些纠结呀
    cyokvip
        5
    cyokvip  
       2016-11-16 06:37:11 +08:00 via iPhone
    会不会是 crosswalk 导致的
    lokk666
        6
    lokk666  
       2016-11-16 09:47:21 +08:00   ❤️ 1
    我的 config 里面 splash 是这样设置的:
    <preference name="SplashScreen" value="screen"/>
    <preference name="SplashScreenDelay" value="1000"/>
    <preference name="FadeSplashScreen" value="true"/>
    <preference name="SplashMaintainAspectRatio" value="true"/>
    <preference name="ShowSplashScreenSpinner" value="false"/>
    <preference name="SplashShowOnlyFirstTime" value="false"/>
    <preference name="FadeSplashScreenDuration" value="500"/>
    crosswalk 是这样设置的:
    <preference name="xwalkVersion" value="19+"/>
    <preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect"/>
    <preference name="xwalkMode" value="embedded"/>
    <preference name="xwalkMultipleApk" value="true"/>
    qweweretrt515
        7
    qweweretrt515  
    OP
       2016-11-16 13:03:33 +08:00
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <widget id="com.ionicframework.myapp743207" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>哇哈哈</name>
    <description>啊啊啊啊啊啊啊.</description>
    <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:*"/>
    <platform name="android">
    <allow-intent href="market:*"/>
    <icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
    <icon src="resources\android\icon\drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources\android\icon\drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources\android\icon\drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources\android\icon\drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
    <splash src="resources\android\splash\drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources\android\splash\drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources\android\splash\drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources\android\splash\drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources\android\splash\drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources\android\splash\drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources\android\splash\drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources\android\splash\drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources\android\splash\drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources\android\splash\drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
    </platform>
    <platform name="ios">
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
    </platform>
    <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="SplashScreenDelay" value="0"/>
    <preference name="FadeSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="0"/>
    <preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
    <preference name="SplashScreen" value="screen"/>
    <feature name="StatusBar">
    <param name="ios-package" onload="true" value="CDVStatusBar"/>
    </feature>
    <plugin name="cordova-plugin-device" spec="~1.1.3"/>
    <plugin name="cordova-plugin-console" spec="~1.0.4"/>
    <plugin name="cordova-plugin-whitelist" spec="~1.3.0"/>
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.0"/>
    <plugin name="cordova-plugin-statusbar" spec="~2.2.0"/>
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
    <icon src="resources\android\icon\drawable-xhdpi-icon.png"/>
    </widget>


    这个是我的
    qweweretrt515
        8
    qweweretrt515  
    OP
       2016-11-16 13:19:52 +08:00
    @lokk666 谢谢你,我按照你的配置文件修改了,修改成了你的代码,点击运行,瞬间就出现了那个画面,但是接下来黑屏了 8 秒多, 所以可能问题出在 黑屏阶段,不晓得如何 优化这个时间
    lokk666
        9
    lokk666  
       2016-11-16 15:50:45 +08:00   ❤️ 1
    qweweretrt515
        10
    qweweretrt515  
    OP
       2016-11-16 16:11:28 +08:00
    @lokk666 这个方案似乎也不行,它用的 ionic1 我用的 2 那个组件不存在, 看来有些麻烦了,我回头再弄弄看, 刚才我发现了官方提供的 demo ,打包后,打开 还是延迟了 10 秒, 由此推测,可能代码和配置没有问题, 有可能是我机器的环境 有问题,我先把其他地方搞定,回头换个环境打包 ,在看看,非常感谢你的热心帮忙
    IJustmaogepao
        11
    IJustmaogepao  
       2016-11-16 17:11:14 +08:00
    换台手机试试,有可能真是手机硬件不行了。。话说 ionic 在 Android 端的表现确实没有 ios 端的好
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2090 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 01:44 · PVG 09:44 · LAX 18:44 · JFK 21:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.