簡體   English   中英

Android App登錄Cordova

[英]Android App Sign in Cordova

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

我已經在Play商店中創建了帳戶。 另外,我檢查了多個鏈接以使其正常工作。

如何使用Cordova命令行界面創建簽名的APK文件?

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

我很少擔心密鑰文件。

根據Cordova文檔,我們可以使用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": ""
        }
    }
}

以上來自Cordova網站的代碼,但我找不到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。

由於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. 在您的Cordova項目文件夾中創建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": "" } } 

    相對路徑從您的Cordova項目文件夾到keystore文件夾。

  5. 從控制台運行cordova build android --release ,例如cordova build android --release ,gradle現在將獲取build.json文件並找到您的密鑰庫。

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM