Release signing in gradle.properties for Android

后端 未结 6 1021
故里飘歌
故里飘歌 2021-01-30 23:20

So I\'m trying to convert all of my ant build scripts to gradle, and I\'ve been able to find ample resources and documentation on all of it except how to configure signing in th

6条回答
  •  生来不讨喜
    2021-01-31 00:03

    I was able to do it with the following. I tried @Xav's solution, but it would complain during the release validation step, if I didn't have the properties set. I'm sure this is a recent change due to the framework changing a lot. I just wanted to help by pointing out that with the else at the very end, I was able to force the release signingConfig to null. Now both signed and unsigned releases happen depending on the presence of the gradle.properties.

    signingConfigs {
        release {
            keyAlias = "blue_sleep"
        }
    }
    
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    
    if (project.hasProperty('storeFile') &&
            project.hasProperty('storePassword') &&
            project.hasProperty('keyPassword')) {
        android.signingConfigs.release.storeFile = file(storeFile)
        android.signingConfigs.release.storePassword = storePassword
        android.signingConfigs.release.keyPassword = keyPassword
    } else {
        android.buildTypes.release.signingConfig = null
    }
    

    Some other useful notes, you can put the gradle.properties in ~/.gradle/ if you don't want it sitting in the project folder. Also you can set the storeFile property with an absolute path like this: storePath=file:///Users/nick/Dropbox/mycompany.keystore

提交回复
热议问题