Skip to main content
deleted 61 characters in body
Source Link
Arpit Patel
  • 8.1k
  • 5
  • 64
  • 80

My answere is slightly different from @cfprabhuFirst Check your version code and version name if you are updating your app. And make sure you have a previous keystore.

If you are updating app then follow step 1,3,4.

(2) Copy zipalign file paste into your generate release apk filefolder usually in below path

D:\projects\Phonegap\Example> cordova build --release android

or

My answere is slightly different from @cfprabhu

(2) Copy zipalign file into your generate release apk file usually in below path

D:\projects\Phonegap\Example> cordova build --release android

or

First Check your version code and version name if you are updating your app. And make sure you have a previous keystore.

If you are updating app then follow step 1,3,4.

(2) Copy zipalign file paste into your generate release apk folder usually in below path

added 8 characters in body
Source Link
Arpit Patel
  • 8.1k
  • 5
  • 64
  • 80

EgsExample:

EgsExample:

Egs:

Egs:

Example:

Example:

Source Link
Arpit Patel
  • 8.1k
  • 5
  • 64
  • 80

My answere is slightly different from @cfprabhu

Step 1:

Goto your cordova project for generate our release build:

D:\projects\Phonegap\Example> cordova build --release android 

Then, we can find our unsigned APK file in platforms/android/ant-build. In our example, the file was

if u used ant-build

yourproject/platforms/android/ant-build/Example-release-unsigned.apk 

OR

if u used gradle-build

yourProject/platforms/android/build/outputs/apk/Example-release-unsigned.apk 

Step 2:

Key Generation:

Syntax:

keytool -genkey -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days> 

if keytool command not recognize do this step

Check that the directory the keytool executable is in is on your path. (For example, on my Windows 7 machine, it's in C:\Program Files (x86)\Java\jre6\bin.)

Egs:

keytool -genkey -v -keystore NAME-mobileapps.keystore -alias NAMEmobileapps -keyalg RSA -keysize 2048 -validity 10000 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

Step 3:

Place the generated keystore in D:\projects\Phonegap\Example\platforms\android\ant-build

To sign the unsigned APK, run the jarsigner tool which is also included in the JDK:

Syntax:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore <keystorename <Unsigned APK file> <Keystore Alias name> 

If it doesn't reconize do these steps

(1) Right click on "This PC" > right-click Properties > Advanced system settings > Environment Variables > select PATH then EDIT.

(2) Add your jdk bin folder path to environment variables, it should look like this:

"C:\Program Files\Java\jdk1.8.0_40\bin".

Egs:

D:\projects\Phonegap\Example\platforms\android\ant-build> 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.

Step 4:

Finally, we need to run the zip align tool to optimize the APK:

if zipalign not recognize then

(1) goto your android sdk path and find zipalign it is usually in android-sdk\build-tools\23.0.3

(2) Copy zipalign file into your generate release apk file usually in below path

D:\projects\Phonegap\Example> cordova build --release android

or

yourproject/platforms/android/ant-build/Example-release-unsigned.apk

D:\projects\Phonegap\Example\platforms\android\ant-build> zipalign -v 4 Example-release-unsigned.apk Example.apk 

OR

D:\projects\Phonegap\Example\platforms\android\ant-build> C:\Phonegap\adt-bundle-windows-x86_64-20140624\sdk\build-tools\android-4.4W\zipalign -v 4 Example-release-unsigned.apk Example.apk 

Now we have our final release binary called example.apk and we can release this on the Google Play Store.