Tuesday, December 7, 2010

signing apk to publish in android app store using keytool and jarsigner

To publish an android application in android market, we need to sign it using jarsigner.

Signing the apk file is very easy, we need to sign for at least 50yrs to publish in android market.

Follow the simple steps to do it.

Step 1:
Create a folder named "keytools" and make a sub folder in that called "keys".

Step 2:
In Eclipse Package Exp window, right click on your project and select Android Tools -> Exports Unsigned Application Package and Save in keytools folder.

Step 3:
Go to your java jdk folder and check jarsigner and keytools is available or not. Path is something like following "C:\Program Files\Java\jdk1.6.0_18\bin"

The the jarsigner and keytools are not available, its not possible to sign the application. Download the files from net and put it in bin.

Step 4:
Open the CMD and navigate to your "keytools" folder. Now the "keytools" folder will be containing .apk file and keys folder.

type the following in your CMD
C:\"Program Files"\Java\jdk1.6.0_18\bin\keytool -genkey -alias myapp.keystore -keyalg RSA -validity 20000 -keystore keys/myapp.keystore

and press enter

Enter keystore password: "SECRET PASSWORD"
Re-enter new password: "SECRET PASSWORD"
What is your first and last name? "Abbas"
What is the name of your Organization unit? "Mobileveda"
What is the name of your Organization? "eMahatva private Limited"
What is the name of your city or locality? "Coimbatore"
What is the name of your state or providence? "TamilNadu"
what is the two-letter country code for this unit? "IN"
is CN=Abbas C=IN correct?
"YES"
Enter key password for
: (press enter button)

Following things may change
1) jdk1.6.0_18 -> your jdk folder name
2) myapp -> your application name.
3) 20000 is number of dates
4) Personal information.

STEP 6:

type the following in CMD

C:\"Program Files"\Java\jdk1.6.0_18\bin\jarsigner -verbose -keystore keys/myapp.keystore -signedjar myapp_signed.apk myapp.apk my.keystore

Enter Passphase for keystore: "Enter your password previously given"
adding: META-INF/MINFEST.MF
.
.
.
.
Signing: classes.dex

Thats it.

Check your keystore folder.

Thanks.