Noobs guide to signing an APK with a Private Key
Credit:
Tommytomatoe - For walking me through the setup/process/commands.
What you'll need to sign an APK.
SDK found here>> Java SDK
*For most users the java_ee_sdk-6u3-jdk7-windows.exe will be the one selected.
*After Install, restart your PC.
Next, open your command prompt
Type: cd C:\Program Files\Java\jre1.6.0_07\bin
*It highly likely, the jre1.6.... will be different. If it's close, then select it. I prefer to type cd c:\pro(pressing tab will automatically complete/find the remaining part of the directory)
If you're on Windows 7, the correct path is
Creating your Private Key
Make sure you're in the directory stated above. We will now create a signed key. Below is an example of what we're going to do. I'll break it down in noob terms after.
skin.keystore meaning
The part of the command that contains your information will be skin.keystore and 12215. The "skin" part of skin.keystore is your release key name. I named my skin because this key will be for all the Skins I upload to the market.
[Q] Do I need to have .keystore after my key name?
[A] Yes. It must look like: skin.keystore otherwise the command will not be complete.
12215 meaning
This is like a second password. Remember this, because it will be referenced when signing an APK. I used 12215. You can use johnsmith or anything else.
keytool -genkey -v -keystore skin.keystore -alias 12215 -keyalg RSA -keysize 2048 -validity 10000
Here is an example of the above:
**IMPORTANT
After you press enter to create the key, it will prompt you for a password. The program mask your password so others won't see it. So when you type it will appear as if no password is being entered.
Your key is stored in the directory you created it in. You won't need to find the file when signing an APK, because it's stored for you already. I'll go into detail of how to access your password in the next step.
How to sign an APK with the Private Key you created.
Anytime you sign an APK, you'll need to open command prompt then type:
*Keep in mind your jdk1.6.0... might be different than the above.
The following is an example of what you'll copy and paste into command prompt.
In the above example, "DRAG-DROP-RENAME-APK-NAME" is telling you to drag your APK into the command prompt and to rename it. Example below.
You can see below my command prompt after I dragged and dropped my apk into cmd. I also deleted "DRAG-DROP alias" from the command line to make it easier to see the changes I'm doing.
After you drag and drop, rename your apk to "New-NOVSKIN1.apk", shown below.
Below you'll see, after I renamed the apk, I dragged and dropped the same apk from above into the command directory again. This time, we're not going to rename it. Instead, after you drop it a second time into command prompt, we're going to type our alias at the end. Pictured below:
**NOTE
The reason we drag and drop is to SAVE TIME. Tommytomatoe showed me this shortcut and it saves a ton of time from having to type everything out.
After entering this command, and executing it, the apk will now be signed. Congrats!
Credit:
Tommytomatoe - For walking me through the setup/process/commands.
What you'll need to sign an APK.
SDK found here>> Java SDK
*For most users the java_ee_sdk-6u3-jdk7-windows.exe will be the one selected.
*After Install, restart your PC.
Next, open your command prompt
Type: cd C:\Program Files\Java\jre1.6.0_07\bin
*It highly likely, the jre1.6.... will be different. If it's close, then select it. I prefer to type cd c:\pro(pressing tab will automatically complete/find the remaining part of the directory)
If you're on Windows 7, the correct path is
Code:
c:\program files\Java\jdk1.7.0_01\bin
Creating your Private Key
Make sure you're in the directory stated above. We will now create a signed key. Below is an example of what we're going to do. I'll break it down in noob terms after.
Code:
keytool -genkey -v -keystore $KEYSTORE -alias $ALIAS -keyalg RSA -keysize 2048 -validity 10000
skin.keystore meaning
The part of the command that contains your information will be skin.keystore and 12215. The "skin" part of skin.keystore is your release key name. I named my skin because this key will be for all the Skins I upload to the market.
[Q] Do I need to have .keystore after my key name?
[A] Yes. It must look like: skin.keystore otherwise the command will not be complete.
12215 meaning
This is like a second password. Remember this, because it will be referenced when signing an APK. I used 12215. You can use johnsmith or anything else.
keytool -genkey -v -keystore skin.keystore -alias 12215 -keyalg RSA -keysize 2048 -validity 10000
Code:
keytool -genkey -v -keystore SAMPLE.keystore -alias SAMPLE -keyalg RSA -keysize 2048 -validity 10000
-TommytomatoeIn the above my key is called "SAMPLE.keystore". Its alias (kind of like an additional password) is "SAMPLE". After you hit enter it will prompt for password. When you type it won't show up on screen (to protect your password)
Here is an example of the above:
-TommytomatoeKeep in mind, if you don't remember your alias you won't be able to use your key
**IMPORTANT
After you press enter to create the key, it will prompt you for a password. The program mask your password so others won't see it. So when you type it will appear as if no password is being entered.
Your key is stored in the directory you created it in. You won't need to find the file when signing an APK, because it's stored for you already. I'll go into detail of how to access your password in the next step.
How to sign an APK with the Private Key you created.
Anytime you sign an APK, you'll need to open command prompt then type:
Code:
cd c:\Program Files\Java\jdk1.6.0_26\bin
The following is an example of what you'll copy and paste into command prompt.
Code:
jarsigner -verbose -keystore skin.keystore -signedjar DRAG-DROP-RENAME-APK-NAME DRAG-DROP alias
In the above example, "DRAG-DROP-RENAME-APK-NAME" is telling you to drag your APK into the command prompt and to rename it. Example below.
You can see below my command prompt after I dragged and dropped my apk into cmd. I also deleted "DRAG-DROP alias" from the command line to make it easier to see the changes I'm doing.
After you drag and drop, rename your apk to "New-NOVSKIN1.apk", shown below.
Below you'll see, after I renamed the apk, I dragged and dropped the same apk from above into the command directory again. This time, we're not going to rename it. Instead, after you drop it a second time into command prompt, we're going to type our alias at the end. Pictured below:
**NOTE
The reason we drag and drop is to SAVE TIME. Tommytomatoe showed me this shortcut and it saves a ton of time from having to type everything out.
After entering this command, and executing it, the apk will now be signed. Congrats!
Last edited: