We do apps, htm5, css3, animations. And we do them with love.
An easy trick to automatically sign release Android applications built with Ionic + Cordova.
If you are into Ionic and app development you know how important signing apps is, and how it can become a headache the process.
Ionic documentation for app signing goes into using tools like jarsigner or zipalign, but there is a way faster and handy trick I use for signing an Android app built with Ionic.
The tools: If you don't have a keystore yet you'll need to install Java JDK and Android SDK tools. I prefer to install the whole (huge and fat) Android Studio cause it comes packed with a lot of usefull tools and candies.
First of all we'll need a keystore. A keystore is just an encryted file that holds aour signatures. Like in real life, signatures are used by Google to prove that the application comes from an authorized developer. To generate our keystore we will use the JDK keytool command. If you plan to use the SDK tools I suggest to add them to the PATH environment variable of your OS. On Windows the JDK binaries folder is located in:
Just type keytool in you console and see if it is available to the path you are.
After setting up JDK tools we need to enter our Ionic folder, let's assume our app is called AwesomeApp and our company is called AwesomeCompany we will issue the following commands:
keytool -genkey -v -keystore awesomecompany.keystore -alias awesomekeyalias -keyalg RSA -keysize 2048 -validity 10000
After that command you will be presented with few questions about your company and other crap stuff, the only important one is the password.
Enter keystore password: HAXX0RPR00FPA55W0RD
What is your first and last name?
[Unknown]: Mickey Mouse
What is the name of your organizational unit?
[Unknown]: App Development Group
What is the name of your organization?
What is the name of your City or Locality?
What is the name of your State or Province?
What is the two-letter country code for this unit?
Is CN=Mickey Mouse, OU=App Development Group, O=nasa.gov, L=Paris, ST=UG, C=UK correct?
If everything was correct we should now have a file called
awesomecompany.keystorein our Ionic app folder.
FOR GOD'S SAKE KEEP THIS FILE AND RELATIVE PASSWORDS SECURE! this is your signature, if you loose it you won't be able to submit any app upgrades to the Google Console, if you got it stealed anyone will be able to impersonate you and submit an app in your place.
Here comes the interesting part. Now that we created our keystore file we just need to instruct the build process to use that file to automatically sign an app whenever we build the release apk.Move the keystore inside the platform/android folder and within the same folder create a new text file named release-signing.properties. Inside the newly created file put the following declarations:
According to our previous example, our release-signing.properties file will look as follows:
Voilà, for now on every time you will build your app with ionic cordova build android --release you will get both a signed and unsigned apks.