1.在module下面新建一个keystore.properties文件
其中文件内容为
注意soreFile后直接跟签名文件的路径就可以,不需要加引号
2.在module下面的build.gradle中加入
//用于加载 keystore.properties 文件
def keystorePropertiesFile =file("keystore.properties")
//Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
注意在android{}前引入
3.signingConfigs {
config { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } 4.
buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.config } debug { signingConfig signingConfigs.config } }