Generate non-debug apk from ionic

后端 未结 5 1918
悲&欢浪女
悲&欢浪女 2020-12-31 09:36

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 generat

5条回答
  •  孤独总比滥情好
    2020-12-31 10:18

    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

提交回复
热议问题