前言
工作随笔,方便记起
1.在工程gradle.properties的文件中
STORE_PASSWORD = store密码
KEY_PASSWORD = key密码
KEY_ALIAS = key alias
2.在工程Module的build.gradle文件中
apply plugin: 'com.android.application'
android {
compileSdkVersion COMPILE_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
applicationId "com.sir.app.test"
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
versionCode 1
versionName "1.0.0"
}
//添加签名文件配置(将signingConfigs{}放到了buildType{}的后面,会导致编译的时候无法找到)
signingConfigs {
debug {
try {
storeFile file("D:\\Test.jks")
storePassword STORE_PASSWORD
keyAlias KEY_ALIAS
keyPassword KEY_PASSWORD
} catch (ex) {
throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
}
}
release {
try {
storeFile file("D:\\Test.jks")
storePassword STORE_PASSWORD
keyAlias KEY_ALIAS
keyPassword KEY_PASSWORD
} catch (ex) {
throw new InvalidUserDataException("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
}
}
}
buildTypes {
release {
minifyEnabled false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
}
}