2017-06-24 68 views
0

我正嘗試從我的Mac中的cordova構建已簽名的應用程序。每當我運行cordova build android --release它釋放未簽名的apk。Android應用程序登錄Cordova

我已在Play商店中創建帳戶。此外,我檢查了多個鏈接,讓這個工作。

How to create a signed APK file using Cordova command line interface?

http://cordova.apache.org/docs/en/6.x/guide/platforms/android/index.html#signing-an-app

我有一個關於密鑰文件很少關注。

根據科爾多瓦文檔,我們可以使用build.json或Gradle來構建簽名的apk。

{ 
    "android": { 
     "debug": { 
      "keystore": "../android.keystore", 
      "storePassword": "android", 
      "alias": "mykey1", 
      "password" : "password", 
      "keystoreType": "" 
     }, 
     "release": { 
      "keystore": "../android.keystore", 
      "storePassword": "", 
      "alias": "mykey2", 
      "password" : "password", 
      "keystoreType": "" 
     } 
    } 
} 

以上代碼來自科爾多瓦網站,但我無法找到build.json文件。

這是來自gradle的代碼。

You can also specify signing properties by including a .properties file and pointing to it with the cdvReleaseSigningPropertiesFile and cdvDebugSigningPropertiesFile Gradle properties (see Setting Gradle Properties). The file should look like this: 

storeFile=relative/path/to/keystore.p12 
storePassword=SECRET1 
storeType=pkcs12 
keyAlias=DebugSigningKey 
keyPassword=SECRET2 
storePassword and keyPassword are optional, and will be prompted for if omitted. 

但我不知道從哪裏得到詳細信息,如storePassword KeyPassword DebugSigningKey。

我正在使用最新版本的Cordova 7.0.1。

回答

1

由於gradle無法找到用於簽名您的應用的密鑰庫,因此您只能獲得未簽名的APK。

爲了解決這個問題,你需要做以下(這就像你在Windows做的,應該是在Mac上一樣):

  1. 使用類似keytool -genkey -v -keystore C:\mykeystore\CordovaRelease.keystore -alias CordovaRelease -keyalg RSA -keysize 2048 -validity 10000請確保創建通過控制檯密鑰庫你安裝了JRE。
  2. 系統會要求您提供CN,OU,...以及要設置的密碼,請選擇一個。
  3. 如果要使用不同的密鑰庫用於調試/發佈,你可以創建另一個密鑰庫
  4. 在科爾多瓦的項目文件夾中創建build.json文件和引用類似"android": { "debug": { "keystore": "..\mykeystore\CordovaDebug.keystore", "storePassword": "secretpassword", "alias": "CordovaDebug", "password" : "secretpassword", "keystoreType": "" }, "release": { "keystore": "..\mykeystore\CordovaRelease.keystore", "storePassword": "", "alias": "CordovaRelease", "password" : "secretpassword", "keystoreType": "" } }的相對路徑從科爾多瓦項目文件夾轉到密鑰庫密鑰庫夾。
  5. 從控制檯運行Cordova構建,如cordova build android --release,gradle現在將採用build.json文件並找到您的密鑰庫。

希望這會有所幫助。

+0

感謝您的回答。 – Ironic

+0

我是否需要在json文件中提供secretpassword和其他詳細信息,或者我需要使用上面的代碼而不更改它。 – Ironic

+0

你也可以使用jar簽名器,然後將zip對齊。使用jar簽名器時,它會提示你輸入你的keyphrase。之後,你將不得不調整它 –