apply plugin: 'com.android.application'
//正式地址
def API_RELEASE_HOST = "\"http://www.baidu.com/release/website/\""
//测试地址
def API_DEV_HOST = "\"http://www.baidu.com/debug/website/\""
android {
signingConfigs {
release {
keyAlias 'key0'
keyPassword '******'
storeFile file('./keystore/App.key.jks')
storePassword '********'
}
}
compileSdkVersion 26
defaultConfig {
applicationId "com.android.test"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "2.0.1.5"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
flavorDimensions "1"
lintOptions {
abortOnError false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
signingConfig signingConfigs.release
}
}
productFlavors {
develop_1offical_address {//给开发人员使用正式地址
buildConfigField "String", "API_HOST", "${API_RELEASE_HOST}"
}
develop_0test_address {//给开发人员使用测试地址
buildConfigField "String", "API_HOST", "${API_DEV_HOST}"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def fileName = new File("app_" +
buildType.name + "_v" + defaultConfig.versionName
+ "_${releaseTime()}.apk")
def outFile = output.outputFile
if (outFile != null && outFile.name.endsWith('.apk')) {
outputFileName = fileName
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
}
def releaseTime() {
return new Date().format("MM_dd_HH_mm")
}
build.gradle的一些打包配置
最新推荐文章于 2024-05-13 10:17:24 发布