Build Signed Android App for Playstore using Command prompt
Open command prompt and stay in your working directory. From there you need to fire some command so that app will be build for playstore, which is technically called signed APK/Build.
But before this make sure, you have already set the path of set of tools so that it set of commands will work in your development machine.
- Android SDK on Path
- Cordova application ready with Android platform added to it
- You have set the right App release version in config.xml of your cordova application
- You have set the right bundle Identifier/App-ID in config.xml, this is most important, as you can not change this once you will release your application.
- jarsigner tool should be available in your machine
- zipalign tool should be available in your machine
Following are the steps to build release APK
Remove the unwanted plugin from your cordova application
cordova plugin rm org.apache.cordova.console
Set the proper version and Application ID/Bundle ID/ APP-ID in config.xml file.
Now use following command to build a release APK.
cordova build --release android
Then, we can find our unsigned APK file in platforms/android/ant-build.
You will find your APK file under following location of your project directory.
Generate KeyStore and Signed APK for Playstore:
As per Google Playstore and Android Guidelines, the Mobile application that you want to make public on playstore, first that needs to be signed using keystore file. Keystore file is nothing but a java based JAR signer. As Android is based on Java language, so playstore do follows that concept.
Using following command to create a keystore file in your development machine
keytool -genkey -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days>
Example for above stntax
keytool -genkey -v -keystore NAME-mobileapps.keystore -alias NAMEmobileapps -keyalg RSA -keysize 2048 -validity 10000
Above command will ask for following information is a command prompt mode
1 2 3 4 5 6 7
keystore password? : xxxxxxx What is your first and last name? : xxxxxx What is the name of your organizational unit? : xxxxxxxx What is the name of your organization? : xxxxxxxxx What is the name of your City or Locality? : xxxxxxx What is the name of your State or Province? : xxxxx What is the two-letter country code for this unit? : xxx<
Then the Key store has been generated with name as NAME-mobileapps.keystore
Place the generated keystore in
To sign the unsigned APK, run the jarsigner tool which is also included in the JDK:
Following is the synax
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore <keystorename <Unsigned APK file> <Keystore Alias name>
Example of usage of above syntax
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore NAME-mobileapps.keystore Example-release-unsigned.apk xxxxxmobileapps
Enter KeyPhrase as 'xxxxxxxx'
This signs the apk in place.
Finally, we need to run the zip align tool to optimize the APK:
zipalign -v 4 Example-release-unsigned.apk Example.apk
zipalign -v 4 Example-release-unsigned.apk myApp.apk
Now we have our final release myApp.apk and we can release this on the Google Play Store.