对于未签名的 APK:只需将 signingConfig 设置为 null。它会给你 appName-debug-unsigned.apk
debug {
signingConfig null
}
并从构建菜单构建。享受
对于签名的 APK:
signingConfigs {
def keyProps = new Properties()
keyProps.load(rootProject.file('keystore.properties').newDataInputStream())
internal {
storeFile file(keyProps.getProperty('CERTIFICATE_PATH'))
storePassword keyProps.getProperty('STORE_PASSWORD')
keyAlias keyProps.getProperty('KEY_ALIAS')
keyPassword keyProps.getProperty('KEY_PASSWORD')
}
}
buildTypes {
debug {
signingConfig signingConfigs.internal
minifyEnabled false
}
release {
signingConfig signingConfigs.internal
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
keystore.properties 文件
CERTIFICATE_PATH=./../keystore.jks
STORE_PASSWORD=password
KEY_PASSWORD=password
KEY_ALIAS=key0