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. org.json.JSONObject与com.google.gson.Gson

    org.json库为JSON创始人编写的解析JSON的java库,Gson为Google为我们提供的解析JSON格式数据的库. Gson里最重要的对象有2个Gson 和GsonBuilder. Gso ...

  2. BZOJ 2339 卡农(组合数学)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2339 题意: 思路: i64 Pow(i64 a,i64 b,i64 mod){    ...

  3. mac更新node

    今天在用 yeoman 的时候,提示对 npm 和 node 的版本有要求,为了决绝以后遇到的一些类似的问题,我决定定期对 node 和 npm 进行更新. npm的更新: $ sudo npm in ...

  4. Android_PendingIntent的使用

        PendingIntent介绍 PendingIntent可以看作是对Intent的一个封装,但它不是立刻执行某个行为,而是满足某些条件或触发某些事件后才执行指定的行为. PendingInt ...

  5. bzoj4048 3928

    羞耻,分组赛上考的,竟然没想出来, 对坐标离散化后区间dp即可,竟然还双倍经验 ; ..,..] of longint; v:..] of longint; a,b,h:..] of longint; ...

  6. UVa 11400 Lighting System Design【DP】

    题意:给出n种灯泡,分别给出它们的电压v,电源费用k,每个灯泡的费用c,和所需灯泡的数量l,问最优方案的费用 看的紫书= = 首先是dp[i]为灯泡1到i的最小费用, dp[i]=min(dp[i], ...

  7. HTMLayout界面CSSS样式解析笔记

    HTMLayout学习笔记 by BBDXF 一.界面篇 学习界面需要有一定的HTML.CSS认知,如果你问为什么,那就当我白说. 由于界面库官方没有给一个完善的User guide,所有的学习都靠自 ...

  8. ti processor sdk linux am335x evm /bin/setup-package-install.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-package-install.sh hacking # 说明: # 本文主要对T ...

  9. Android Configuration change引发的问题及解决方法(转)

    之前在学习Fragment和总结Android异步操作的时候会在很多blog中看到对Configuration Change的讨论,以前做的项目都是固定竖屏的,所以对横竖屏切换以及横竖屏切换对程序有什 ...

  10. JetBrains优秀工具推荐

    1.JAVA开发工具 IDEA IDEA 全称 IntelliJ IDEA,是Java语言开发的集成环境,IntelliJ在业界被公认为最好的Java开发工具之一,尤其在智能代码助手.代码自动提示.重 ...