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. 配置centos 7 mysql

    http://www.cnblogs.com/starof/p/4680083.html 一.系统环境 yum update升级以后的系统版本为 [root@yl-web yl]# cat /etc/ ...

  2. GridView官方教程及示例

    Grid View GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The gri ...

  3. POJ 2409 Let it Bead(polay计数)

    题目链接:http://poj.org/problem?id=2409 题意:给出一个长度为m的项链,每个珠子可以用n种颜色涂色.翻转和旋转后相同的算作一种.有多少种不同的项链? 思路: (1) 对于 ...

  4. Android Touch事件分发机制

    参考:http://blog.csdn.net/xiaanming/article/details/21696315 参考:http://blog.csdn.net/wangjinyu501/arti ...

  5. Android中View转换为Bitmap及getDrawingCache=null的解决方法

    1.前言 Android中经常会遇到把View转换为Bitmap的情形,比如,对整个屏幕视图进行截屏并生成图片:Coverflow中需要把一页一 页的view转换为Bitmap.以便实现复杂的图形效果 ...

  6. Struts2注解配置之@Namespace(四)

    今天开始学习@Namespace注解. 还是先看一段代码: package com.example.actions; import org.apache.struts2.convention.anno ...

  7. Spring MVC定义拦截器

    拦截器: package sy.Interceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http ...

  8. 省常中模拟 Test3 Day2

    matrix 找规律 题意:给定一个 N*N 的只有 0 和 1 的矩阵,有 Q 个操作,分三种:1. 将某行上的所有数字取反:2. 将某列上的所有数字取反:3. 输出 sum{ a[i][j]*a[ ...

  9. directdraw的多画面显示rgb

    // showpicDlg.cpp : 实现文件 // #include "stdafx.h" #include "showpic.h" #include &q ...

  10. Linux 平台下 YUM 源配置 手册

    Redhat/Centos 系的Linux 平台,推荐使用YUM 来安装相关依赖包. 安装方式有两种,一种是使用本地的YUM,一种使用在线的YUM. 1         在线YUM 源 如果操作系统能 ...