目录
- 目录
- Android平台的apk打包
- iOS平台生成构建版本的注意事项
- Android平台的具体参考
- Publishing your app
这里进行记录,方便查找:
Android平台的apk打包
针对Android平台来说:
旧的(这个操作不太正确,或者说不太好,误导大家了,尴尬):
cordova plugin rm cordova-plugin-console
cordova build --release android
cd platforms
cd android
cd build
cd outputs
cd apk
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -tsa https://timestamp.geotrust.com/tsa -keystore my-release-key.keystore android-release-unsigned.apk wanchett
zipalign -v 4 android-release-unsigned.apk WanCheTT.apk
新的(2017-02-23):
cordova plugin rm cordova-plugin-console
ionic build android --release --prod --device -- --keystore="../android.keystore" --storePassword=android --alias=mykey --password=myKeyPassword
cd platforms
cd android
cd build
cd outputs
cd apk
zipalign -v 4 android-release.apk WanCheTT.apk
// 或者直接(将在项目的根目录下生存WanCheTT.apk)
zipalign -v 4 ./platforms/android/build/outputs/apk/android-release.apk WanCheTT.apk
其中 ionic build android –prod –device 中的 –prod 表示启用aot;–device 将要求略过白屏启动时间。
打包好APP后,还需要对APP进行加固。可以使用“乐固”,通过“乐固”进行加固后,下载加固后的安装包,重新进行签名即可。
iOS平台生成构建版本的注意事项
Xcode8 iOS App上传详细流程
- 调试过程中 product -》 scheme -》edit scheme run 为 debug;发布时改为release;
- APP中有推送功能的话,注意开启 推送 功能(使用XCode打开项目进行配置);
- 考虑设置APP是否允许横屏显示;
- 在info.list处添加权限的说明: iOS-Xcode上传后iTunes Connect构建版本不显示
Android平台的具体参考:
Publishing your app
Now that we have a working app, we are ready to push it live to the world! Since the Ionic team already submitted the Todo app from this guide to the app store, chances are you’ll want to follow this chapter with a new app that you make on your own.
So first, we need to generate a release build of our app, targeted at each platform we wish to deploy on. Before we deploy, we should take care to adjust plugins needed during development that should not be in production mode. For example, we probably don’t want the debug console plugin enabled, so we should remove it before generating the release builds:
$ cordova build --release android
This will generate a release build based on the settings in your config.xml
. Your Ionic app will have preset default values in this file, but if you need to customize how your app is built, you can edit this file to fit your preferences. Check out the config.xml file documentation for more information.
Next, we can find our platforms/android/build/outputs/apk
. In our example, the file was platforms/android/build/outputs/apk/HelloWorld-release-unsigned.apk
. Now, we need to sign the unsigned APK and run an alignment utility on it to optimize it and prepare it for the app store. If you already have a signing key, skip these steps and use that one instead.
Let’s generate our private key using the keytool
command that comes with the JDK. If this tool isn’t found, refer to the installation guide:
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
You’ll first be prompted to create a password for the keystore. Then, answer the rest of the nice tools’s questions and when it’s all done, you should have a file called my-release-key.keystore
created in the current directory.
Note: Make sure to save this file somewhere safe, if you lose it you won’t be able to submit updates to your app!
To sign the unsigned APK, run the jarsigner
tool which is also included in the JDK:
$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
This signs the apk in place. Finally, we need to run the zip align tool to optimize the APK. The zipalign
tool can be found in /path/to/Android/sdk/build-tools/VERSION/zipalign
. For example, on OS X with Android Studio installed, zipalign
is in ~/Library/Android/sdk/build-tools/VERSION/zipalign
:
$ zipalign -v 4 HelloWorld-release-unsigned.apk HelloWorld.apk
Now we have our final release binary called HelloWorld.apk
.