示例代码:
首先,需要设置keystore.properties文件:
storeFile=/path/to/your/keystore.file
storePassword=your_keystore_password
keyAlias=your_key_alias
keyPassword=your_key_password
然后在您的build.gradle文件中添加以下内容:
Properties properties = new Properties()
properties.load(project.rootProject.file('keystore.properties').newDataInputStream())
android {
...
signingConfigs {
release {
storeFile file(properties['storeFile'])
storePassword properties['storePassword']
keyAlias properties['keyAlias']
keyPassword properties['keyPassword']
}
}
buildTypes {
release {
...
signingConfig signingConfigs.release
}
}
...
}
这将使用您在keystore.properties文件中指定的信息对您的应用程序进行签名。