Skip to content

Instantly share code, notes, and snippets.

@manigedit
Created December 7, 2019 12:27
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 manigedit/d5260b2d0e53c2a737f8639b081a581f to your computer and use it in GitHub Desktop.
Save manigedit/d5260b2d0e53c2a737f8639b081a581f to your computer and use it in GitHub Desktop.

APK genreation guidelines for the fiinwallet Project

The APK genration process is achieved by Cordova. The suggested version for Cordova CLI is 7.1.0 , You can go with the latest version also, In case an Error is encountered, follow the below command to install Cordova CLI 7.1.0

$ sudo npm unistall cordova -g

$ sudo npm install -g cordova@7.1.0

$ npm install

Preparing the Android platform

$ cordova platform add android

Generating the unsigned apk

$ ionic cordova build --release android

You must have Android Tools and SDK installed on your machine along with the PATH variable specified. This command will generate an unsigned apk in the directory displayed at the output (e.g. platforms/android/app/build/outputs/apk/release ).

Genrating a signed APK to run it on Devices

Find our unsigned APK file in platforms/android/build/outputs/apk. In our example, the file was platforms/android/build/outputs/apk/release/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.

$ 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 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 release-unsigned.apk fiinwallet.apk

Now we have our final release binary called fiinwallet.apk

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