Android 中文API:Signing Your Applications(為APK簽名)

來源:互聯網
上載者:User

標籤:


Android要求所有的app在安裝之前,都要安裝數位憑證。Android利用數位憑證去確定app的作者,該認證不需要認證辦法機構簽署。Android app經常使用自我簽署憑證。App開發人員持有認證的private key。

SigningOverview

你可以簽名以debug mode或者release mode兩種方式簽名一個app。你可以在debug模式下開發,在release模式下發布。在debug mode下Android SDK產生了簽署憑證。在release mode下籤名一個apk,你需要產生自己的認證。

Signing in Debug Mode

在debug模式下,簽名apk使用的認證是由Android SDK tools產生的。該認證帶有一個已知密碼的private key(私匙),以至於你可以每次run 和debug應用程式的時候,不需要輸入密碼。

當你在run or debug 你的項目的時候,Android studio 在debug模式在會自動簽名你的app。

      在debugmode下,你可以在虛擬機器或者裝置上運行,debug應用,但是不發行就緒它。

預設的,the debug mode 的配置使用一個擁有已知的密碼和一個已知的預設default key的debug keystore(密匙庫)。這個debug keystore 位於$HOME/.android/debug.keystore,如果該檔案不存在,則在編譯過程中會自動建立。這個debugbuild type被debugSigningConfig 自動設定。

Signing in Release Mode

在release mode中,簽名app應該使用你自己的認證。

1.   create a keystore。A keystore 是包含private key一個二進位檔案,你應該把這個檔案放在可靠安全的地方。

2.   create a private key。private key 代表著等同於app的一個實體。例如一個人或者一個公司。

3.   為app module 模組增加簽名配置。

...
android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            storeFile file("myreleasekey.keystore")
            storePassword "password"
            keyAlias "MyReleaseKey"
            keyPassword "password"
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}
...


5.   執行assembleRelease 編譯任務。

產生的簽名apk 在app/build/apk/app-release.apk

 作者有話說:如果您需要Android中文API,請掃一掃下面的二維碼,做技術,我們認真的。




Android 中文API:Signing Your Applications(為APK簽名)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.