Reputation: 328
I'm trying to sign the unsigned APK. I followed this link.
My steps:
$ cordova build --release android
(success)$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name - keyalg RSA -keysize 2048 -validity 10000
(success)$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name
(got problem)The problem is:
jarsigner: unable to open jar file: HelloWorld-release-unsigned.apk
Then i followed this link.
$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -my-release-key.keystore F:\mobile\moto\whatever_the_path_is_to_your_apk_file\HelloCordova-release-unsigned.apk alias_name
(got problem)the problem is:
Illegal option: -my-release-key.keystore
Can anyone help me. Thank you.
Upvotes: 8
Views: 19603
Reputation: 61
Steps to sign Corodva apk using keytool, jarsigner and zipalign are:
keytool -genkey -v -keystore android.keystore -alias android_app -keyalg RSA -keysize 2048 -validity 10000
keytool -importkeystore -srckeystore android.keystore -destkeystore android.keystore -deststoretype pkcs12
It will create two files in Project_root_dir as android.keystore (with pkcs12) and android.keystore.old (without pkcs12)
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore android.keystore app-release-unsigned.apk android_app
First time you'll get below error as:
jarsigner: unable to open jar file: app-release-unsigned.apk
Then you just need to move .apk file from
/Project_root_dir/platforms/android/app/build/outputs/apk/release/app-release unsigned.apk
in to Project_root_dir/
Then again run the jarsigner command above, it will sign apk successfully.
zipalign -v 4 app-release-unsigned.apk app-release.apk
Your apk is signed successfully, you can publish it in play store.
I hope this will help you.
Upvotes: 6
Reputation: 517
You need to run all the commands in the projects root directory, and the important thing, you should move your apk file after running $ cordova build --release android
from AwesomeProject\platforms\android\app\build\outputs\apk\release
to the project root directory.
Upvotes: 0
Reputation: 2960
Just use absolute path instead of relative path as:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore myApp.keystore E:\myApp\platforms\android\app\build\outputs\apk\release\app-release-unsigned.apk myApp
Upvotes: 0
Reputation: 41
Follow this path and please write your keystore name as well as your alias name:-
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore salonify-release-key.keystore platforms/android/app/build/outputs/apk/release/app-release-unsigned.apk salonify
Upvotes: 0
Reputation: 579
follow what @manzapanza have wrote, I also had to download zipalign from http://dl.dropbox.com/u/34706306/zipalign
move zipalign into Android mv /Users/YOUR_USER_NAME/Downloads/zipalign /Users/YOUR_USER_NAME/Library/Android/sdk/tools
Give the execute permissions:
chmod 777 /Users/YOUR_USER_NAME/Library/Android/sdk/tools/zipalign
Do the command jarsigner: jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore yourkeystore.jks app-release-unsigned.apk aliayourkeystore
Upvotes: 0
Reputation: 6215
You need to remove the -
in front of the keystore
file and add the flag -keystore
:
$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore F:\mobile\moto\whatever_the_path_is_to_your_apk_file\HelloCordova-release-unsigned.apk alias_name
Generally I use these commands to generate a release build apk
that I will publish in the Google Play Store:
cd ~/Projects/myappname/
cordova build android --release
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore certificates/myappname-cert.keystore -storepass myappname -keypass myappname platforms/android/ant-build/CordovaApp-release-unsigned.apk myappname
jarsigner -verify -verbose -certs platforms/android/ant-build/CordovaApp-release-unsigned.apk
~/android-sdk-macosx/build-tools/21.1.2/zipalign -v 4 platforms/android/ant-build/CordovaApp-release-unsigned.apk releases/android/myappname1.0.0.apk
Note that I created the dir. certificates
with the .keystore certificate, and the dir. releases/android
where I save all signed apk releases.
To generate a new keystore
file with a new password
:
keytool -genkey -v -keystore certificates/my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
Upvotes: 11