I am using ionic framework to generate apk for android platform.
After running ionic build android
, an android-debug.apk is generated. How can I generate a non-debug apk which is smaller and faster?
I am using ionic framework to generate apk for android platform.
After running ionic build android
, an android-debug.apk is generated. How can I generate a non-debug apk which is smaller and faster?
This is my android release shell script
IFY
clear
gulp
ionic build --release android
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore "path/to/your/keystore" "platforms/android/build/outputs/apk/android-release-unsigned.apk" "keystore alias" -storepass xxx -keypass xxx
/path/to/android-sdk/build-tools/23.0.2/zipalign -v 4 "platforms/android/build/outputs/apk/android-release-unsigned.apk" "android-release.apk"
rm "platforms/android/build/outputs/apk/android-release-unsigned.apk"
In cordova 6.2.0 you can release an apk with follwoing commands. Since ionic is a wrapper around cordova, this should work.
cd cordova/ #change to root cordova or ionic folder
platforms/android/cordova/clean #clean if you want
cordova build android --release -- --keystore="/path/to/keystore" --storePassword=password --alias=alias_name #password will be prompted if you have any
As ionic CLI is based on cordova CLI, you can use, directly:
ionic build android --release
Also, if you are worried about optimization, you might find interesting usign zipalign, in order to align data on 4-byte boundaries, thus causing the app to reduce the amount of RAM used. Once you have build the release apk with the previous command, you can run:
zipalign -v 4 yourReleaseApp.apk zipalignedReleaseApp.apk
Basically, as Jan commented, you should use the command: cordova build android --release
. You can take a look at the official guide from Ionic about how to publish your app.
1. To release build for Android, we can use the following cordova cli command
ionic cordova build --release android
2. Build apk is unsigned. Need to sign it. That’s why create private key with keytool of JDK. we can use following cli command
keytool -genkey -v –keystore mykey.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
keep the mykey.keystore file in a safe place for future use. if the keytool is not work then copy path of this file and set it in the system environment variable.
3. Now sign the unsigned apk with the following command
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore mykey.keystore projectpath\platforms\android\build\outputs\apk\android-release-unsigned.apk alias_name
4. At last optimize the apk file.
zipalign -v 4 projectpath\platforms\android\build\outputs\apk\android-release-unsigned.apk projectpath\platforms\android\build\outputs\apk\android-release.apk
for more details you can visit following url Build Release APK of Android Application from ionic