2014-12-29 36 views

回答

2
  1. 刪除控制檯插件:

    D:\projects\Phonegap\Example> cordova plugin rm org.apache.cordova.console 
    
  2. 要生成Android的發佈版本,我們首先需要做一個小的變化,以在平臺/機器人找到了AndroidManifest.xml文件。

    編輯文件並將「android:debuggable」更改爲「false」。現在

  3. 我們可以告訴科爾多瓦生成我們的發佈版本:

    D:\projects\Phonegap\Example> cordova build --release android 
    

    然後,我們可以找到我們的平臺/安卓/螞蟻構建APK未簽名的文件。在我們的例子中,文件是platforms/android/ant-build/Example-release-unsigned.apk

  4. 注意:您要創建密鑰,請繼續執行以下步驟。

    密鑰生成語法:

    keytool -genkey -v -keystore .keystore -alias -keyalg -keysize -validity 
    

    例子:

    keytool -genkey -v -keystore NAME-mobileapps.keystore -alias NAMEmobileapps -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? : xx 
    

    那麼關鍵商店已與名稱爲名稱 - mobileapps.keystore

  5. 將產生生成的密鑰庫在D:\projects\Phonegap\Example\platforms\android\ant-build

    要簽署的APK未簽名,運行jarsigner工具也被包含在JDK:

    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore 
    

    例子:

    D:\projects\Phonegap\Example\platforms\android\ant-build> jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore NAME-mobileapps.keystore Example-release-unsigned.apk xxxxxmobileapps 
    Enter KeyPhrase as 'xxxxxxxx' 
    

    這簽署APK到位。

  6. 最後,我們需要運行zip對齊工具來優化APK。此時可以採取如下的:

    D:\projects\Phonegap\Example\platforms\android\ant-build> zipalign -v 4 Example-release-unsigned.apk Example.apk 
    
    D:\projects\Phonegap\Example\platforms\android\ant-build> C:\Phonegap\adt-bundle-windows-x86_64-20140624\sdk\build-tools\android-4.4W\zipalign -v 4 Example-release-unsigned.apk Example.apk 
    

    現在,我們有我們的最終版本的二進制稱爲example.apk,我們可以釋放這對谷歌Play商店。

+0

非常感謝! – user12920

相關問題