2016-02-03 171 views
4

我正在嘗試簽署未簽名的APK。我跟着this link無法簽署未簽名的APK

我的步驟:

  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(有問題)

的問題是:

jarsigner: unable to open jar file: HelloWorld-release-unsigned.apk

然後我跟着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(有問題)

的問題是:

Illegal option: -my-release-key.keystore

誰能幫我。謝謝。

回答

5

您需要刪除-keystore文件的前面加了標誌-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 

一般來說,我使用這些命令生成一個release build apk,我會在谷歌Play商店發佈:

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 

請注意,我創建了dir。帶有.keystore證書的certificates以及目錄。 releases/android我保存所有簽名的apk版本。

生成一個新的keystore請用一個新password

keytool -genkey -v -keystore certificates/my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 
+0

當我使用這個去掉'-' ='$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 my-release-key.keystore F:\ mobile \ moto \ whatever_path_is_to_your_apk_file \ HelloCordova-release-unsigned.apk alias_name'告訴我'唯一可以指定的別名' – syareen

+0

然後我試了這個'jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore -storepass try -keypass try C:\ Users \ Users \ desktop \ try \ platform \ android \ build \ outputs \ apk \ android-release- unsigned.apk嘗試它'告訴我'jarsigner錯誤:java.lang.RuntimeException:密鑰庫加載:密鑰庫被調和,或密碼不正確' – syareen

+0

我更新了我的答案添加命令以生成一個新密碼的新密碼文件。 – manzapanza

0

關注你@manzapanza已經寫了,我也只好從http://dl.dropbox.com/u/34706306/zipalign 移動的zipalign下載的zipalign到安卓mv /Users/YOUR_USER_NAME/Downloads/zipalign /Users/YOUR_USER_NAME/Library/Android/sdk/tools給執行權限:

chmod 777 /Users/YOUR_USER_NAME/Library/Android/sdk/tools/zipalign做命令jarsigner:jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore yourkeystore.jks app-release-unsigned.apk aliayourkeystore