世界未解之谜之----------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文件的时候).如果每次去改也 ...
随机推荐
- mysql5.1安装图解教程
mysql5.1安装图解教程 曾经为了要搭建模拟平台,从内地网站学习到台湾网站,其中必不可少的一项就是MySQL,那时候正好普遍用5.1,所以也很习惯用MySQL5.1版本! 下面就以MySQL5.1 ...
- 服务器raid状态监控
参考 http://hwraid.le-vert.net/wiki 查看raid芯片 lspci -v 02:00.0 SCSI storage controller: LSI Logic / Sym ...
- 2017.10.28 QB模拟赛 —— 上午
题目链接 T1 1e18 内的立方数有 1e6个 直接枚举可过 二分最优 考场用set 死慢.. #include <cstdio> int t; long long p; int ma ...
- JAVA去掉HTMl以及CSS样式
封装方法如下 public String delHTMLTag(String htmlStr){ String regEx_style="<style[^>]*?>[\\s ...
- 解决Zend加密的PHP页面出现Incompatible file format的问题
错误如图: 致命错误:不兼容的文件格式可能的原因: 1.文件本身加密的问题,很有可能你用的Zend进行加密了,但是因为版本的问题,很有可能是你的主机上的Zend Optimizer版本太低了.2.文件 ...
- 高精度水题(POJ2109)
题目链接:http://poj.org/problem?id=2109 double 可以虽然可以表示10^-307~~~10^208,但是精确度只有16位,这个题有bug. #include < ...
- Nginx+Tomcat+memcached高可用会话保持
Nginx+Tomcat+memcached高可用会话保持 文章来源dyc2005 一.概述 之前文章已经描述了企业高可用负载相关的架构及实现,其中常用的nginx或haproxy,LVS结合ke ...
- 2017.11.16 JavaWeb-------第八章 EL、JSTL、Ajax技术
第八章 EL.JSTL.Ajax技术 ~~ EL (expression language) 是表达式语言 ~~ JSTL(JSP Standard Tag Library) 是开源的JSP标准标签库 ...
- Spring Boot的Maven插件Spring Boot Maven plugin详解
Spring Boot的Maven插件(Spring Boot Maven plugin)能够以Maven的方式为应用提供Spring Boot的支持,即为Spring Boot应用提供了执行Mave ...
- Python 初始—(项目 目录结构)
在os 包下,给出 import os ,os.path.abspath(__file__)获取当前文件的相对路径,os.path.dirname 获取当前文件所在的文件夹目录 print(os.pa ...