1. 程式人生 > >Android之build.gradle配置簽名

Android之build.gradle配置簽名

1 問題

android簽名除了我們用android studio

build->generate Signed Apks ...

我們還可以自己用build.gradle構建,容易忘記還是記錄下來

 

 

 

2 配置如下

1) build.gradle檔案如下

android {
    ...
    signingConfigs {
        release {
            def prpe = new Properties()
            def input = project.rootProject.file('local.properties').newInputStream();
            prpe.load(input)
            storeFile new File(prpe.getProperty('path.store.file'))
            storePassword prpe.getProperty('path.store.password')
            keyAlias prpe.getProperty('path.alias')
            keyPassword prpe.getProperty('path.alias.password')
        }
    }
   
    buildTypes {
        debug {
            debuggable true
        }

        release {
            debuggable false
            minifyEnabled true
            signingConfig signingConfigs.release
            proguardFiles 'proguard.cfg'
        }
    }
    ...
}

 

 

 

 

2) local.properties檔案如下

path.store.file=/.../.../***.keystore
path.alias=***
path.store.password=***
path.alias.password=***