今天运行项目,运行的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的更多相关文章

  1. React Native Android gradle下载慢问题解决

    很多人会遇到 初次运行 react-native run android的时候 gradle下载极慢,甚至会失败的问题 如下图 实际上这个问题好解决的 首先 把对应版本的gradle下载到本地任意一个 ...

  2. 利用 Android Gradle 瘦身 apk

    http://devyang.me/blog/2014/11/11/li-yong-android-gradleshou-shen-apk/ apk瘦身一般有两条线, 去除无用的代码,例如引用一个比较 ...

  3. Android Gradle 技巧之一: Build Variant 相关

    Build Variant android gradle 插件,允许对最终的包以多个维度进行组合. BuildVariant = ProductFlavor x BuildType 两个维度 最常见的 ...

  4. The Android Gradle Plugin and Gradle version-compatibility

    http://tools.android.com/tech-docs/new-build-system/version-compatibility Version Compatibility Post ...

  5. Android Gradle实用技巧——多渠道打包

    友盟有很多不错的功能,例如渠道统计等. 想要做渠道统计,有一个要求就是要在manifest文件中添加各个渠道的配置.只有一两个渠道还好说,但是渠道多了的话,手动修改然后打包简直是噩梦. 幸好现在And ...

  6. Android Gradle Plugin指南(六)——高级构建定制

    原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Advanced-Build-Customization ...

  7. [Android]Gradle 插件 DiscardFilePlugin(class注入&清空类和方法)

    以下内容为原创,欢迎转载,转载请注明 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/6732128.html Android Gradle 插件 Di ...

  8. Android Gradle 指定 Module 打包

    Android Gradle 指定 Module 打包 项目中有许多的可以直接独立运行的 Module ,如何在 Gradle 中将签名文件配置好了,那么就不需要普通的手动点击 Generate Si ...

  9. Android Gradle manifestPlaceholders 占位符详解

    Android Gradle manifestPlaceholders 占位符详解 在实际项目中,AndroidManifest里十几个地方的值是需要动态的改变(生成apk文件的时候).如果每次去改也 ...

随机推荐

  1. Linux与Windows区别——总结中

    一:在Linux系统中,每一个文件都多加了很多的属性进来,尤其是用户组的概念 二:Windows下面一个文件是否具有执行的能力是通过“扩展名”来判断的,如:.exe,.bat,.com等 Linux下 ...

  2. April 9 2017 Week 15 Sunday

    In the evening one may praise the day. 入夜方能赞美白昼. I think that could be understand in different ways, ...

  3. 257. Binary Tree Paths (dfs recurive & stack)

    Given a binary tree, return all root-to-leaf paths. Note: A leaf is a node with no children. Example ...

  4. 表面积最小(POJ3536)

    题目链接:http://poj.org/problem?id=3536 在体积固定的情况下,表面积最小时的长,宽,高. 这里枚举长,宽,根据体积计算高. #include <iostream&g ...

  5. 【转】Activity生命周期详解

    三个循环 提供两个关于Activity的生命周期模型图示帮助理解:                                           图1 图2 从图2所示的Activity生命周期 ...

  6. JavaEE权限管理系统的搭建(一)--------项目中用到的知识点概括

    转战Java有一段时间了,.net 已不再开发的新的工程,基本上在维护,最近大半年时间在学习Java,今天抽空将学习的到的知识,应用到了一个权限管理系统的小项目中,特此记录一下.代码如有不对之处,希望 ...

  7. 微信小程序之setData原理以及几点关于小程序的吐槽

    小程序不方便之处: 1: 想做个获取列表中每个item所在的对应滚动条的高度在哪里,或者元素本身的高度也不好获取,极其不方便,网上看的别人做的滚动条相关的,都是写死或者已知的item高度,目前没找到正 ...

  8. React dangerouslySetInnerHTML - 将HTML字符串解析为html样式显示

    <div dangerouslySetInnerHTML={{ __html: curriculumDesc }}></div>

  9. cordova-plugin-themeablebrowser 0.2.17 "ThemeableBrowser"ionic跳转外链插件在ios中heardBar会遮住内容的bug

    ionic+angular的app项目中需要在App打开一个外部的url链接,用了这个插件发现在iPhone手机中会出现toolbar挡住url页面内容 解决方法: 在原有基础上加上statusBar ...

  10. MySQL - Mac下安装MySQL

    1. 去官网下载dmg的安装文件. 2. 下载完成后,运行安装文件,按步骤进行安装,安装完成后会弹出一个框显示临时密码! 3. 编辑~/.bashrc文件,配置快速启动/停止/重启/cdhome/别名 ...