syareen syareen - 1 year ago 202
Android Question

unable to sign the unsigned APK

I'm trying to sign the unsigned APK. I followed this link.

My steps:

  1. $ cordova build --release android

  2. $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name - keyalg RSA -keysize 2048 -validity 10000

  3. $ 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.

  1. $ 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.

Answer Source

You need to remove the - in front of the keystorefile 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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download