Skip to content

Instantly share code, notes, and snippets.

@ayoubkhan558-zz
Forked from nvanselow/Build Android Binary.md
Last active April 22, 2022 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ayoubkhan558-zz/8be041a31ddd3e794a687900f5224531 to your computer and use it in GitHub Desktop.
Save ayoubkhan558-zz/8be041a31ddd3e794a687900f5224531 to your computer and use it in GitHub Desktop.
Generate Android Signed APK File for Google Play with Ionic

STEPS TO CREATE ANDROID APK USING IONIC 4

Add android plateform

In the command line run ionic cordova platform add android

Generate Icons and splash for all the platforms

ionic cordova resources

Prepare the platform

ionic cordova prepare android

Build Android Binary APK

ionic cordova build android --prod --release ionic build android --release

Generate Keystore File

keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-alias Example keytool -genkey -v -keystore sodasulf-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias sodasulf

Run keytool -genkey -v -keystore my-release-key.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias alias_name Example keytool -genkey -v -keystore sodasulf-key.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias sodasulf

Change "my-release.keystore" and "alias_name" to match your app and preferences.

Keep this file in a safe place. If you lose it you may be unable to upload revisions of your app to the store.

Release APK, Generate RSA key by opening CMD at project Path & execute this command

Then sign the Release APK by the generated keystore file, use below command

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore sodasulf-key.keystore G:\SodaSulfApp\platforms\android\app\build\outputs\apk\release\sodasulf.apk sodasulf

Example jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore sodasulf-key.keystore G:\SodaSulfApp\sodasulf.apk sodasulf

*Change "my-release-key.keystore" and "alias_name" to match your app. You may also need to change the name of the apk file.* 

(absolute path instead of relative)
You may need to change the name of the apk file. The signed apk will be in the main folder unless you specify a different folder.

Then zip-align the signed APK by using below command

zipalign -v 4 platforms/android/build/outputs/apk/android-release-unsigned.apk MyApp.apk zipalign -v 4 G:\SodaSulfApp\platforms\android\app\build\outputs\apk\release\sodasulf.apk sodasulf.apk C:\Android\sdk\build-tools\29.0.0\zipalign -v 4 G:\SodaSulfApp\platforms\android\app\build\outputs\apk\release\sodasulf.apk sodasulf.apk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment