Android Gradle - load signing config from external file

前端 未结 4 702
旧巷少年郎
旧巷少年郎 2020-12-15 07:39

In Gradle for Android it seems to be commons practice to define your signing config for release build like this:

android {
    signingConfigs {
        debu         


        
4条回答
  •  独厮守ぢ
    2020-12-15 08:34

    For Kotlin Script (build.gradle.kts)

    Put a file signing.properties where the module specific build.gradle.kts is found. Don't forget to add it to your .gitignore file!

    signing.properties

    storeFilePath=/home/willi/example.keystore
    storePassword=secret
    keyPassword=secret
    keyAlias=myReleaseSigningKey
    

    build.gradle.kts

    android {
        // ...
        signingConfigs {
            create("release") {
                val properties = Properties().apply {
                    load(File("signing.properties").reader())
                }
                storeFile = File(properties.getProperty("storeFilePath"))
                storePassword = properties.getProperty("storePassword")
                keyPassword = properties.getProperty("keyPassword")
                keyAlias = "release"
            }
        }
    
        buildTypes {
            getByName("release") {
                signingConfig = signingConfigs.getByName("release")
                // ...
            }
        }
    }
    

提交回复
热议问题