android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.xxx'
defaultConfig {
applicationId "com.xxx.xxx"
minSdkVersion 14
targetSdkVersion 19
versionCode 71
versionName "2.4.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
signingConfigs {
debug {
// No debug config
}
release {
storeFile file("../key.keystore")
storePassword "123456"
keyAlias "xxxmobilecloud"
keyPassword "123456"
}
}
buildTypes {
debug {
// 显示Log
buildConfigField "boolean", "LOG_DEBUG", "true"
//是否打开debuggable开关
debuggable true
//是否打开jniDebuggable开关
jniDebuggable true
//是否混淆
minifyEnabled false
//是否zip对齐
zipAlignEnabled true
//签名配置
signingConfig signingConfigs.release
//manifestPlaceholders = [ENV_SERVICE: "pre"]
manifestPlaceholders = [ENV_SERVICE: "pre", ENV_CLIENT: "debug", SUNING_APPKEY: "24f1cfc0bb784feca110eb4793791f50", SUNING_CHANNEL:"msop"]
}
release {
// manifestPlaceholders = [ENV_SERVICE: "pre"]
// 不显示Log
buildConfigField "boolean", "LOG_DEBUG", "false"
//是否打开debuggable开关
debuggable false
//是否打开jniDebuggable开关
jniDebuggable false
//是否混淆
minifyEnabled true
//是否zip对齐
zipAlignEnabled true
// 移除无用的resource文件 [使用必须打开混淆]
shrinkResources true
//混淆配置文件
proguardFiles 'proguard.cfg'
//签名配置
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName ="aaa" + "_v${defaultConfig.versionName}_${variant.productFlavors[0].name}.apk"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
packagingOptions {
exclude 'META-INF/INDEX.LIST'
exclude 'META-INF/io.netty.versions.properties'
}
productFlavors {
pre {
manifestPlaceholders = [ENV_SERVICE: "pre", ENV_CLIENT: "debug", XXX_APPKEY: "12345", XXX_CHANNEL:"aaa"]
}
}
}
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile project(':library')
compile('com.xxx.mobile:xxx:5.3.6.2') {
exclude group: 'com.xxx.mobile', module: 'xxx'
}
}
关于lint的配置
android {
lintOptions {
// true--关闭lint报告的分析进度
quiet true
// true--错误发生后停止gradle构建
abortOnError false
// true--只报告error
ignoreWarnings true
// true--忽略有错误的文件的全/绝对路径(默认是true)
//absolutePaths true
// true--检查所有问题点,包含其他默认关闭项
checkAllWarnings true
// true--所有warning当做error
warningsAsErrors true
// 关闭指定问题检查
disable 'TypographyFractions','TypographyQuotes'
// 打开指定问题检查
enable 'RtlHardcoded','RtlCompat', 'RtlEnabled'
// 仅检查指定问题
check 'NewApi', 'InlinedApi'
// true--error输出文件不包含源码行号
noLines true
// true--显示错误的所有发生位置,不截取
showAll true
// 回退lint设置(默认规则)
lintConfig file("default-lint.xml")
// true--生成txt格式报告(默认false)
textReport true
// 重定向输出;可以是文件或'stdout'
textOutput 'stdout'
// true--生成XML格式报告
xmlReport false
// 指定xml报告文档(默认lint-results.xml)
xmlOutput file("lint-report.xml")
// true--生成HTML报告(带问题解释,源码位置,等)
htmlReport true
// html报告可选路径(构建器默认是lint-results.html )
htmlOutput file("lint-report.html")
// true--所有正式版构建执行规则生成崩溃的lint检查,如果有崩溃问题将停止构建
checkReleaseBuilds true
// 在发布版本编译时检查(即使不包含lint目标),指定问题的规则生成崩溃
fatal 'NewApi', 'InlineApi'
// 指定问题的规则生成错误
error 'Wakelock', 'TextViewEdits'
// 指定问题的规则生成警告
warning 'ResourceAsColor'
// 忽略指定问题的规则(同关闭检查)
ignore 'TypographyQuotes'
}
}