世界未解之谜之----------Android Gradle
今天运行项目,运行的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'
}
世界未解之谜之----------Android Gradle的更多相关文章
- React Native Android gradle下载慢问题解决
很多人会遇到 初次运行 react-native run android的时候 gradle下载极慢,甚至会失败的问题 如下图 实际上这个问题好解决的 首先 把对应版本的gradle下载到本地任意一个 ...
- 利用 Android Gradle 瘦身 apk
http://devyang.me/blog/2014/11/11/li-yong-android-gradleshou-shen-apk/ apk瘦身一般有两条线, 去除无用的代码,例如引用一个比较 ...
- Android Gradle 技巧之一: Build Variant 相关
Build Variant android gradle 插件,允许对最终的包以多个维度进行组合. BuildVariant = ProductFlavor x BuildType 两个维度 最常见的 ...
- The Android Gradle Plugin and Gradle version-compatibility
http://tools.android.com/tech-docs/new-build-system/version-compatibility Version Compatibility Post ...
- Android Gradle实用技巧——多渠道打包
友盟有很多不错的功能,例如渠道统计等. 想要做渠道统计,有一个要求就是要在manifest文件中添加各个渠道的配置.只有一两个渠道还好说,但是渠道多了的话,手动修改然后打包简直是噩梦. 幸好现在And ...
- Android Gradle Plugin指南(六)——高级构建定制
原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Advanced-Build-Customization ...
- [Android]Gradle 插件 DiscardFilePlugin(class注入&清空类和方法)
以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/6732128.html Android Gradle 插件 Di ...
- Android Gradle 指定 Module 打包
Android Gradle 指定 Module 打包 项目中有许多的可以直接独立运行的 Module ,如何在 Gradle 中将签名文件配置好了,那么就不需要普通的手动点击 Generate Si ...
- Android Gradle manifestPlaceholders 占位符详解
Android Gradle manifestPlaceholders 占位符详解 在实际项目中,AndroidManifest里十几个地方的值是需要动态的改变(生成apk文件的时候).如果每次去改也 ...
随机推荐
- 二种方法安装卸载Windows服务的命令
第一种方法:通过Dos命令安装系统服务1. 开始 运行输入 cmd 进入dos窗口2. cd命令进入到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727目录下, ...
- sql分组数据去重
#分组获得每个机柜里服务器占用的机架总数,如552807e6-b428-4184-b219-ae368c68ddb3占用4个 mysql> select cabinet_uuid, count( ...
- HTML:::before和::after伪元素的用法
随笔 - 366 文章 - 0 评论 - 392 ::before和::after伪元素的用法 一.介绍 css3为了区分伪类和伪元素,伪元素采用双冒号写法. 常见伪类——:hover,:li ...
- hive自定义UDTF函数叉分函数
hive自定义UDTF函数叉分函数 1.介绍 从聚合体日志中需要拆解出来各子日志数据,然后单独插入到各日志子表中.通过表生成函数完成这一过程. 2.定义ForkLogUDTF 2.1 HiveUtil ...
- Python基础学习之序列(2)
通用序列操作 所有序列类型都可以进行某些特定的操作.这些操作包括:索引(indexing).分片(sliceing).加(adding).乖(multiplying)以及检查某个元素是否属于序列的成员 ...
- 【^.^】hello world~~
一直以来都没有在公共博客上写作的习惯,加之Evernote的强大和方便好用,让我仅仅依赖它就足以满足日常学习笔记的记录和整理. 不过看着Evernote里面记录的大大小小的笔记已经有400+了,觉得应 ...
- MYSQL:随机抽取一条数据库记录
今天我们要实现从随机抽取一条数据库记录的功能,并且抽取出来的数据记录不能重复: 1.首先我们看文章表中的数据: 2.实现功能代码如下: 1 /** * 获取随机的N篇文篇 * @param int $ ...
- JAX-WS @WebParam自定义参数名称无效
在使用myeclipse 自动对service方法类进行创建webservice服务时,默认创建参数命名都是arg0-9 这样就导致生成的xml配置文件命名不规范,需要对参数名称进行修改: myecl ...
- OpenGL学习 Our First OpenGL Program
This shows you how to create the main window with the book’s application framework and how to render ...
- Altium_Designer-怎么将“原理图的更改”更新到“pcb图”?
打开原理图,直击菜单栏>>Design,选择第一项,>>Update PCB Document...在弹出的对话框里面选择执行更改即可将原理图更新到工程下面对应的PCB.也可以 ...