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. printf left justify

    http://www.lemoda.net/c/printf-left-justify/index.html This example program demonstrates how to left ...

  2. 从Uboot到Linux技术内幕

    1. 引言 在专用的嵌入式板子运行 GNU/Linux 系统已经变得越来越流行.一个嵌入式 Linux 系统从软件的角度看通常可以分为四个层次: 1. 引导加载程序.包括固化在固件(firmware) ...

  3. java开发之多线程需要学习和理解的东西

    40个Java多线程问题总结 http://www.codeceo.com/article/40-java-thread-problems.html

  4. android动画坐标定义

    这段时间一直在忙Android的项目,总算抽出点时间休息一下,准备把一些项目用到的Android经验分享一下. 在Android开发过程中,经常会碰到Activity之间的切换效果的问题,下面介绍一下 ...

  5. poj 1054 The Troublesome Frog (暴力搜索 + 剪枝优化)

    题目链接 看到分类里是dp,结果想了半天,也没想出来,搜了一下题解,全是暴力! 不过剪枝很重要,下面我的代码 266ms. 题意: 在一个矩阵方格里面,青蛙在里面跳,但是青蛙每一步都是等长的跳, 从一 ...

  6. 严重: Catalina.stop: java.net.ConnectException: Connection refused: connect

    原因: 1.连接被拒绝,关闭的时候报错.是不是已经关闭了,你又关闭,他当然找不到了. 2.连接被拒绝有可能是服务端连接数到达最高了 3.服务器拒绝连接,ip地址是否写对,端口号正确与否,网络是否通畅, ...

  7. CodeForces Round #296 Div.2

    A. Playing with Paper 如果a是b的整数倍,那么将得到a/b个正方形,否则的话还会另外得到一个(b, a%b)的长方形. 时间复杂度和欧几里得算法一样. #include < ...

  8. Asp.net正则获取html内容

    1.获取div内容 string str = "tt<u>ss</u><div id=\"test\"><div>< ...

  9. ti processor sdk linux am335x evm /bin/commom.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/commom.sh hacking # 说明: # 本文主要对TI的sdk中的common.s ...

  10. Java [Leetcode 260]Single Number III

    题目描述: Given an array of numbers nums, in which exactly two elements appear only once and all the oth ...