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

2016-11-15 16:57:16 +08:00
 qweweretrt515

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

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

5008 次点击
所在节点    问与答
11 条回复
lokk666
2016-11-15 20:49:38 +08:00
你的启动页时间太长了,在 config.xml 里面把 SplashScreenDelay 改小点。希望能帮到你 XD
qweweretrt515
2016-11-15 22:37:54 +08:00
@lokk666 你好,这个值 我写的是 0 ,还有其他地方能优化吗
murmur
2016-11-15 22:39:37 +08:00
你是安卓几呢 ionic 最好要 android4.4 低配真无解
qweweretrt515
2016-11-15 22:51:44 +08:00
@murmur android4.4.4 三星手机 因为后面也要考虑低配手机的用户体验,所以有些纠结呀
cyokvip
2016-11-16 06:37:11 +08:00
会不会是 crosswalk 导致的
lokk666
2016-11-16 09:47:21 +08:00
我的 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
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
2016-11-16 13:19:52 +08:00
@lokk666 谢谢你,我按照你的配置文件修改了,修改成了你的代码,点击运行,瞬间就出现了那个画面,但是接下来黑屏了 8 秒多, 所以可能问题出在 黑屏阶段,不晓得如何 优化这个时间
lokk666
2016-11-16 15:50:45 +08:00
qweweretrt515
2016-11-16 16:11:28 +08:00
@lokk666 这个方案似乎也不行,它用的 ionic1 我用的 2 那个组件不存在, 看来有些麻烦了,我回头再弄弄看, 刚才我发现了官方提供的 demo ,打包后,打开 还是延迟了 10 秒, 由此推测,可能代码和配置没有问题, 有可能是我机器的环境 有问题,我先把其他地方搞定,回头换个环境打包 ,在看看,非常感谢你的热心帮忙
IJustmaogepao
2016-11-16 17:11:14 +08:00
换台手机试试,有可能真是手机硬件不行了。。话说 ionic 在 Android 端的表现确实没有 ios 端的好

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/320705

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX