久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Android 上使用不同密鑰的 Gradle 簽名風格

Gradle signing flavors with different keys on Android(在 Android 上使用不同密鑰的 Gradle 簽名風格)
本文介紹了在 Android 上使用不同密鑰的 Gradle 簽名風格的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的 Android 應用程序有多種版本,我希望除一個之外的所有應用程序都使用相同的密鑰.有一個需要使用不同的密鑰.

I have many flavors of my Android app, and I want all but one to use the same key. There is one that needs to use a different key.

我如何只為 1 種風格的應用覆蓋 signingConfig(但在相同的構建類型中,例如發布")?

How do I override the signingConfig for just 1 flavor of the app (but within the same build type e.g. "release")?

  • 我希望所有構建都默認使用主發布配置.
  • 我只想覆蓋 1 種風味
  • 我希望能夠使用單個 gradlew assembleRelease 命令運行所有發布版本
  • I would like all builds by default to use the main release configuration.
  • I only want to override 1 flavor
  • I want to be able to run all release builds with a single gradlew assembleRelease command

最后一點很重要,因為我目前有超過 120 種不同的口味,而且還在不斷增長.為了單獨定制每一種口味,需要做很多額外的工作.

This last point is important as I currently have over 120 different flavors and growing. In order to customise every single flavor individually is a lot of extra work.

我嘗試過的相關帖子:

從單一構建類型生成使用不同密鑰簽名的多個構建

  • 這需要為每種風味進行配置
  • 它似乎并沒有使用我的自定義 signingConfig 反正

使用 gradle 簽署產品風格

  • 接受的解決方案不起作用(對我而言)
  • 根據評論,這可以通過放置buildTypes 里面的 productFlavors 但我不明白如何做到這一點.
  • accepted solution doesn't work (for me)
  • according to a comment this is possible by putting buildTypes inside the productFlavors but I do not understand how to do this.

在 Gradle 產品風味上調試簽名配置

  • 如博文中所述:使用 Gradle 構建多個版本的 Android 應用
  • 它不工作實際上它完美工作
  • 但它不能很好地適應 119 種口味

總的來說,每個解決方案似乎仍然使用默認的發布配置,而不是我的自定義配置.

Overall, each solution seems to still use the default release config, instead of my custom config.

我的 build.gradle 的重要部分如下所示:

Important parts of my build.gradle look like this:

signingConfigs {
    releaseConfig {
        storeFile file('key')
        storePassword "pass"
        keyAlias "alias"
        keyPassword "pass"
    }

    custom {
        storeFile file('custom_key')
        storePassword "pass"
        keyAlias "alias"
        keyPassword "pass"
    }
}

productFlavors {
    apple {
        applicationId "demo.apple"
    }
    banana {
        applicationId "demo.banana"
    }

    // def customConfig = signingConfigs.custom
    custom {
        applicationId "custom.signed.app"
        // signingConfig customConfig
    }
 }


buildTypes {
    debug {
        applicationIdSuffix ".debug"
    }
    release {
         signingConfig signingConfigs.releaseConfig
         // productFlavors.custom.signingConfig signingConfigs.custom
    }
}

推薦答案

Gradle Plugin User Guide 說你可以:

通過設置每個發布包使用自己的 SigningConfigandroid.productFlavors.*.signingConfig 對象分開.

have each release package use their own SigningConfig by setting each android.productFlavors.*.signingConfig objects separately.

此答案(Debug Signing Config on Gradle Product Flavors)和此博客文章 (使用 Gradle 構建多個版本的 Android 應用).

This is demonstrated in this answer (Debug Signing Config on Gradle Product Flavors) and this blog post (Building Multiple Editions of an Android App with Gradle).

但是,為每種風格指定單獨的 signingConfig 行不能很好地擴展,并且超出了問題的范圍.不幸的是,提供的答案都沒有顯示如何正確覆蓋 signingConfig.

However, specifying a separate signingConfig line for each flavor does not scale well, and was out of scope of the question. Unfortunately none of the provided answers showed how to correctly override a signingConfig correctly.

訣竅來自這個答案(How to get the current selected build variant in gradle?),它展示了如何循環構建變體(以及擴展,風味).

The trick came from this answer (How to get the currently chose build variant in gradle?) which shows how to loop over build variants (and by extension, flavors).

我的解決方案使用循環來設置每種風味的 signingConfig,而不是為此設置單獨的行.這可以很好地擴展.覆蓋"是通過在循環之后指定自定義配置的單行來完成的.

My solution uses a loop to set the signingConfig on each flavor instead of having a separate line for that. This scales perfectly well. The "override" is done with a single line that specifies the custom config after the loop.

將以下代碼放在 buildTypes.release 塊中:

Place the following code inside the buildTypes.release block:

// loop over all flavors to set default signing config
productFlavors.all { flavor ->
    flavor.signingConfig signingConfigs.releaseConfig
}
// override default for single custom flavor
productFlavors.custom.signingConfig signingConfigs.custom

這篇關于在 Android 上使用不同密鑰的 Gradle 簽名風格的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當前風味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風味庫的多風味應用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 欧美一级毛片免费观看 | 中文字幕二区 | 毛片免费在线 | 综合网伊人 | 中文字幕亚洲精品 | 久久精品国产免费一区二区三区 | 日韩欧美国产一区二区 | 一区二区三区免费观看 | 国产乱码精品1区2区3区 | 欧美日韩精品一区二区三区蜜桃 | av国产精品 | 亚洲高清在线观看 | 国产精品片aa在线观看 | 免费国产网站 | 成人深夜福利在线观看 | 亚洲午夜网 | 久久久夜夜夜 | 色婷婷综合网 | 国产精品123区 | 99久久婷婷国产综合精品电影 | 免费h在线 | av久久| 91视视频在线观看入口直接观看 | 日韩色视频 | 精品久| 久久国产一区 | 亚洲美女在线一区 | 精品欧美二区 | 精品一区二区三区四区视频 | 免费的av网站 | 91免费版在线观看 | 99精品一区二区 | 中文字幕在线观看一区 | 欧美日韩视频在线播放 | 99re视频这里只有精品 | 亚洲精品一区二区三区中文字幕 | 91电影在线播放 | 中文字幕1区2区 | 香蕉视频一区二区 | 日韩精品免费视频 | 日本一二区视频 |