7.查看依赖

gradlew [你想查看的module]:dependencies >dependencies.txt

6.buildToolsVersion build tools版本号

compileSdkVersion android sdk版本

5.删除无用资源

android {
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
}
}

4.定义资源类型变量(可以在代码中R.string.ResName调用)

android{
  productFlavors {
dev {
resValue "string", "ResName", "ResValueForDebug"
}
product {
resValue "string", "ResName", "ResValueForProduct"
}
  }
}

3.在build.gradle里面定义常量,在AndroidManifest里面使用

manifestPlaceholders = [app_channel:"google_play"]

在AndroidManifest里面使用${app_channel}

2.在gradle.properties定义常量

在gradle.properties

VALUE_1="一些自定义的内容"
VALUE_2="一些自定义的内容"
VALUE_3="一些自定义的内容"

在build.gradle引用, 注意,下面的VALUE1就是直接引用, 赋值给COSTOM_FIELD这个字段

android{
defaultConfig {
buildConfigField 'String', 'CUSTOM_FIELD', VALUE1
}
}

1.自定义BuildConfig字段

在android模块内添加下面脚本,下面设置之后直接在代码里使用BuildConfig.HOST即可使用

android{
  productFlavors {
dev {
buildConfigField 'String', 'HOST', '"http://api.zzb.com/debug"'
}
product {
buildConfigField 'String', 'HOST', '"http://api.zzb.com/product"'
}
  }
}

build.gradle 使用tips的更多相关文章

  1. Gradle 翻译 tips and recipes 使用技巧 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  2. 解决 Could not find com.android.tools.build:gradle 问题

    今天拉同事最新的代码,编译时老是报如下错误: Error:Could not find com.android.tools.build:gradle:2.2.0.Searched in the fol ...

  3. build.gradle文件介绍

    对于以前用Eclipse开发安卓的小伙伴来说,Gradle文件是陌生的. 不同于Eclipse,而Android Studio 是采用Gradle来构建项目的. 先来介绍最外层目录下的build.gr ...

  4. 怎么将Android studio 的“ build:gradle改低一点”

    参考来源:http://bbs.qcloud.com/thread-17193-1-1.html Error:Execution failed for task ':xxxx:compileDebug ...

  5. Could not find com.android.tools.build:gradle:1.3.0.

    * What went wrong:          A problem occurred configuring project ':TZYJ_Android'.> Could not re ...

  6. Failed to apply plugin [id 'com.android.application'] 和 Could not find com.android.tools.build:gradle:2.XX的最正确的解决方法

    发现android studio是真的可爱啊,上一秒还没问题可以build运行,下一秒就出错...好,你任性,你牛逼.. 说下今天又遇到的两个问题:Failed to apply plugin [id ...

  7. module中build.gradle文件参数含义

    主要是module的build.gradle,截图如下: 01行:apply plugin: 'com.android.application'    表示该module是这个应用程序的module ...

  8. 用Gradle构建时,将密码等敏感信息放在build.gradle之外

    密码 在做版本release时你app的 build.gradle你需要定义 signingConfigs.此时你应该避免以下内容: 不要做这个 . 这会出现在版本控制中. signingConfig ...

  9. 添加 Gradle 依赖与 build.gradle 配置初识

    添加 Gradle 我们可以到我们添加 Maven 依赖的网站 Maven Repository: Search/Browse/Explore http://mvnrepository.com/ 上查 ...

随机推荐

  1. gulp自动刷新插件

    gulp自动刷新的插件很多,但是感觉最好用的还是 browser-sync 插件.如果不想用命令行,也可以使用 browser-sync界面工具 先安装 browser-sync 插件: npm in ...

  2. poj 1185 炮兵阵地(三维状态压缩dP)

    题目:http://poj.org/problem?id=1185 思路: d[i][j][k]表示第i行的状态为第k个状态,第i-1行的状态为第j个状态的时候 的炮的数量. 1表示放大炮, 地形状态 ...

  3. UVa 12563 (01背包) Jin Ge Jin Qu hao

    如此水的01背包,居然让我WA了七次. 开始理解错题意了,弄反了主次关系.总曲目最多是大前提,其次才是歌曲总时间最长. 题意: 在KTV房间里还剩t秒的时间,可以从n首喜爱的歌里面选出若干首(每首歌只 ...

  4. PHP中 对象自动调用的方法:__set()、__get()、__tostring()

    总结: (1)__get($property_name):获取私有属性$name值时,此对象会自动调用该方法,将属性name值传给参数$property_name,通过这个方法的内部 执行,返回我们传 ...

  5. Tomcat 映射虚拟目录

    设置虚拟目录映射一般有两种用途: (1)把整个web应用映射到tomcat中: 如一个testapp的web应用的路径是/opt/testapp,则通过虚拟目录映射可以将其映射到tomcat(weba ...

  6. error LNK2019: 无法解析的外部符号 __imp___CrtDbgReportW

    error LNK2005 and error LNK2019 error LNK2019: unresolved external symbol __imp___CrtDbgReportW refe ...

  7. OK335xS psplash 进度条工作原理 hacking

    #!/bin/sh # # rc This file is responsible for starting/stopping # services when the runlevel changes ...

  8. HDU 1213 How Many Tables (并查集,常规)

    并查集基本知识看:http://blog.csdn.net/dellaserss/article/details/7724401 题意:假设一张桌子可坐无限多人,小明准备邀请一些朋友来,所有有关系的朋 ...

  9. 修改placeholder属性

    input::-webkit-input-placeholder{ font-size:12px;}input:-ms-input-placeholder{ font-size:12px;}input ...

  10. 开源Jabber(XMPP) IM服务器介绍

    一.摘要 这是我粗略读了一遍Jabber协议和相关技术文章后的产物,有些地方不一定准确.在文章中引用的一些代码来自www.jabber.org上的文章. 二. 什么是Jabber    Jabber就 ...