Android

步驟 1: 轉到專案的根目錄並開啟命令列提示符

 cordova build --release android

這會在\ platforms \ android \ build \ outputs \ apk 下生成一個帶有名稱的 unsigned apk

Android 的版本,unsigned.apk

第 2 步: 獲取簽名 apk 的金鑰生成

句法:

 keytool -genkey -v -keystore <keystoreName>.keystore -alias <Keystore AliasName> -keyalg <Key algorithm> -keysize <Key size> -validity <Key Validity in Days>

例:

keytool -genkey -v -keystore ExampleApp.keystore -alias TestExampleApp -keyalg RSA -keysize 2048 -validity 10000

keystore password? : xxxxxxx
What is your first and last name? :  xxxxxx
What is the name of your organizational unit? :  xxxxxxxx
What is the name of your organization? :  xxxxxxxxx
What is the name of your City or Locality? :  xxxxxxx
What is the name of your State or Province? :  xxxxx
What is the two-letter country code for this unit? :  xxx

金鑰庫是在名為 ExampleApp.keystore 的同一資料夾中生成的

步驟 3: 將生成的金鑰庫移動到 \ platforms \ android \ build \ outputs \ apk

\ platforms \ android \ build \ outputs \ apk 下的命令提示符下執行 jarsigner 工具 ******

句法:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore <keystorename <Unsigned APK file> <Keystore Alias name>   

例:

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ExampleApp.keystore android-release-unsigned.apk TestExampleApp

這將生成具有相同名稱的簽名 apk。

第 4 步: zip 對齊工具來優化 APK

 zipalign -v 4 android-release-unsigned.apk android.apk

zipalign 位於\ Android \ sdk \ build-tools \ 23.0.3 \ zipalign 下

這將生成一個名為 android.apk 的已簽名 apk,現在可以將其上傳到 app store