Release signing in gradle.properties for Android

后端 未结 6 1018
故里飘歌
故里飘歌 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:23

    Gradle 1.9 doesn't allow you to define properties. You can add them only to ext now. Small addition to previous answers:

    signingConfigs {
        debug {
            project.ext.loadSign = false
        }
        release {
            project.ext.loadSign = true
        }
    }
    
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.release
        }
    }
    
    if ( project.ext.loadSign ) {
        Properties p = new Properties ()
        p.load ( new FileInputStream ( rootProject.file ( 'keys/sign.properties' ) ) )
    
        android.signingConfigs.release.storeFile file ( p.file )
        android.signingConfigs.release.storePassword p.password
        android.signingConfigs.release.keyAlias p.alias
        android.signingConfigs.release.keyPassword p.keyPassword
    }
    

提交回复
热议问题