1、问题:启动后短暂白屏。

   解决方法:

    (1)隐藏白屏。

          工程目录下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"/>

<feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
    </feature>

        我这里的app.component.ts默认如下:

export class MyApp {
  rootPage = TabsPage;

  constructor(platform: Platform) {
    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();      //隐藏白屏
    });
  }
}

     所以不需要再修改。

 

    (2)加载其他图片

      在index.html加载图片,如:

<div class="appSplash">
<div style="font-size: 30px;text-align: center">这里可以放广告图片</div>
<img src="./assets/img/qr_code.png" alt=""
</div>

参考链接:http://www.jianshu.com/p/102bd23625cb

 

2、去除启动时转的圈圈:config.xml加上<preference name="ShowSplashScreenSpinner" value="false"/>

 

3、问题:APP启动过慢。

     解决方法:打包apk时,加上--prod

     以下是本人的粗略测试:

  红米4X DEVICE READY FIRED AFTER
debug 10.4s 6559ms
debug+prod 4.6s 1522ms

 

 

 

release版本和debug时间差不多。

 

4.打包apk时自动签名

   (1)生成签名文件:

          方法1:利用Android Studio生成。参考:http://www.jianshu.com/p/dfd98ad47af1

          方法2:利用jdk的KeyTool生成。

                    命令行:keytool -genkey -v -keystore appDemo.jks -alias test  -keyalg RSA -keysize 2048 -validity 10000

                              appDemo和test自命名,如图:

                 注:确认信息是否有误时,要输入“是”/“否”。

            可发现目录下有appDemo.jks文件生成。

 

    (2)自动签名设置:

           工程目录/platforms/android目录新建名为release-signing.properties的文件,内容如下:

storeFile=path to keystore
keyAlias=your key alias
storePassword=your store password
keyPassword=you key password

            storeFile为appDemo.jks的路径,且windows下路径应使用Unix下的目录分隔符/。

 

      (3)打包时加上--release即可生成有签名的apk。

           

   

 posted on 2017-05-05 14:40  沫沫小青  阅读(1417)  评论(0编辑  收藏  举报