Signing Android apps on Phonegap for release

Posted
Categorized as Code, Software Tagged , , , , ,

You will need to digitally sign your apps for release if you want to install them on your device for live testing. If not you will get a parse error when installing.

image

We will need to use the keytool from the JDK to create a key we can use to sign our apps whenever we build them (be sure you already added the JDK path to your Environment Variables before proceeding). To do this open your command prompt and navigate to your project folder. Once there enter the command below:

keytool -genkey -v -keystore <FILENAME-OF-YOUR-KEY>.keystore -alias <ALIAS_OF-YOU-KEY> -keyalg RSA -keysize 2048 -validity <DURATION-IN-DAYS>

You will need to change the values in angle brackets (<>). Once you enter the command, answer the questions asked. Remember to take note of the passwords you enter, you will need that in a bit. When you are done you will see a .keystore file on your project folder.

Now create an ant.properties file in your <PROJECT-PATH>platformandroid folder with the following contents:

key.store=D:pathtotheproject<FILENAME-OF-YOUR-KEY>.keystore
key.alias=<ALIAS_OF_YOUR_KEY>
key.store.password=<KEY-PASSWORD>
key.alias.password=<ALIAS-PASSWORD>

Note the double slash () between folder paths.

Now you can build your Phonegap/Cordova app for release with the following command.

cordova build android --release

Leave a Reply