世界未解之谜之----------Android Gradle
2024-10-15 23:27:34
今天运行项目,运行的debug出来的包竟然是命名过的,但是我的buildTypes里面的debug 并没有执行重命名操作。很奇怪,我的猜测是: 执行buildTypes的时候,虽然是assermdebug,但是确实走了release里面的东西
求大神指点:
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.aaa.ccc"
minSdkVersion 14
targetSdkVersion 23
multiDexEnabled true
buildConfigField("String", "ChannelId", '"116118"') //渠道号
}
buildTypes {
debug {
buildConfigField "boolean", "LOG_DEBUG", "true" //log 日志
buildConfigField "String", "URL_CONFIG", "\"huidu\"" // url 配置:official,huidu,fangzhen
minifyEnabled false
zipAlignEnabled false
debuggable true
shrinkResources false
}
release {
minifyEnabled true
proguardFiles 'proguard-project.txt'
debuggable false
buildConfigField "boolean", "LOG_DEBUG", "false"
buildConfigField "String", "URL_CONFIG", "\"official\""
def versionN = getTodayReleaseVersion()
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "baiduapp_v${getVersionName()}_${releaseDay()}_build${versionN}.apk"
output.outputFile = new File(outputFile.parent,fileName)
}
}
}
}
}
productFlavors {
}
lintOptions{
abortOnError false
}
sourceSets{
main {
jniLibs.srcDirs = ['jniLibs']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile project(':plug')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.1.1'
}
def releaseDay(){
return new Date().format("yyyyMMdd",TimeZone.getTimeZone("UTC"))
}
def getTodayReleaseVersion(){
def runTasks = gradle.startParameter.taskNames;
def versionPropsFile = file('buildver.properties')
def today = releaseDay()
if(versionPropsFile.canRead()){
def versionId = 1
def Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def releaseDay = versionProps.get("RELEASE_DAY")
if(releaseDay.equals(today)) {
versionId = versionProps.get('VERSION_NAME').toInteger()
println("-------------"+runTasks);
def isRelase = false
runTasks.each { task ->
if(task.contains("assembleRelease")){
isRelase = true
}
}
if(isRelase){
versionId++
}
}else{
versionProps["RELEASE_DAY"] = today;
}
versionProps['VERSION_NAME'] = versionId.toString()
versionProps.store(versionPropsFile.newWriter(),null)
return versionId.toString();
}else{
versionPropsFile.createNewFile();
def Properties versionProps = new Properties();
versionProps["RELEASE_DAY"] = releaseDay;
versionProps['VERSION_NAME'] = versionId.toString()
versionProps.store(new FileOutputStream(versionPropsFile),null)
}
return "1";
}
def getVersionName(){
def fileManifest = file("src/main/AndroidManifest.xml")
def androidManifest = new XmlSlurper().parse(fileManifest)
return androidManifest.@'android:versionName'
}
最新文章
- iOS开发路线简述
- java的前台与后台
- 每日英語2013.09.09(Email常用單字)
- 从个人的角度谈谈本次GNTC大会的收获
- C#虚方法认识
- 20160129.CCPP体系详解(0008天)
- 节点与坐标系——Cocos2d-x学习历程(十)
- HTML学习(五)链接
- vim - manual -个人笔记
- GirdView分页
- make menuconfig 笔记
- div盒子水平居垂直中的几种方法
- [tomcat] tomcat简析(一)
- shell脚本编写某一文件夹内拷贝某一段文件(有则跳过没有则拷贝)
- java29
- ORM对单表的增删改查
- node封装mysql操作
- 关于sdl_ttf使用字体库加载失败的问题
- sudo: Cannot execute /usr/local/bin/zsh: No such file or directory 问题
- D3——Axes