gradle大体内容
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
// 方法超过65535 做法 还有。。。
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex' // enable multidex
// optional
// dx.additionalParameters += "--main-dex-list=$projectDir/<filename>".toString() // enable the main-dex-list
}
}
android {
compileSdkVersion 8
buildToolsVersion "22.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
//签名
signingConfigs {
//你自己的keystore信息
releaseConfig {
storeFile file("wf.keystore")
storePassword "123456"
keyAlias "wfwf"
keyPassword "654321"
}
debugConfig {
storeFile file("wf.keystore")
storePassword "123456"
keyAlias "wfwf"
keyPassword "654321"
}
}
buildTypes {
release{
minifyEnabled true
signingConfig signingConfigs.releaseConfig
proguardFile 'proguard.cfg'
zipAlignEnabled true
renderscriptOptimLevel 5
}
debug{
minifyEnabled false
signingConfig signingConfigs.debugConfig
proguardFile 'proguard.cfg'
zipAlignEnabled true
renderscriptOptimLevel 5
}
}
// This is important, it will run lint checks but won't abort build
lintOptions {
abortOnError false
}
dexOptions {
incremental true
}
}
不分包
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
//compile 'com.google.android:multidex:0.1'
}
android {
compileSdkVersion 8
buildToolsVersion "22.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
// //签名
// signingConfigs {
// //你自己的keystore信息
// releaseConfig {
// storeFile file("wf.keystore")
// storePassword "123456"
// keyAlias "wfwf"
// keyPassword "654321"
// }
// debugConfig {
// storeFile file("wf.keystore")
// storePassword "123456"
// keyAlias "wfwf"
// keyPassword "654321"
// }
// }
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
// buildTypes {
// release {
// minifyEnabled false
// signingConfig signingConfigs.releaseConfig
// proguardFile 'proguard.cfg'
// zipAlignEnabled true
// renderscriptOptimLevel 5
//
// }
// debug {
// minifyEnabled false
// signingConfig signingConfigs.debugConfig
// proguardFile 'proguard.cfg'
// zipAlignEnabled true
// renderscriptOptimLevel 5
//
// }
// }
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
// afterEvaluate {
// tasks.matching {
// it.name.startsWith('dex')
// }.each { dx ->
// if (dx.additionalParameters == null) {
// dx.additionalParameters = []
// }
// dx.additionalParameters += '--multi-dex' // enable multidex
//
// // optional
// // dx.additionalParameters += "--main-dex-list=$projectDir/<filename>".toString() // enable the main-dex-list
// }
// }
// ...
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
}
混淆,分包
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.3.0'//统计应用方法数
}
}
//Error:(51, 13) Failed to resolve: org.apache.commons:commons-lang3:3.4
//缺少jar包,可以指定一个仓库下载(jcenter)
allprojects{
repositories{
jcenter()
mavenCentral()
}
}
apply plugin: 'android'
//apply plugin: 'com.getkeepsafe.dexcount'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':DXSP_Android')
compile 'com.android.support:multidex:1.0.1'
}
//—multi-dex:多 dex 打包的开关
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex' // enable multidex
dx.additionalParameters +='--set-max-idx-number=48000'//用于控制每一个dex的最大方法个数,写小一点可以产生好几个dex,默认每个 dex 中方法数最大为65536
// optional
// dx.additionalParameters += "--main-dex-list=$projectDir/<filename>".toString() // enable the main-dex-list
}
}
android {
// compileSdkVersion 14
// buildToolsVersion "23.0.1"
// applicationId "com.foundersc.mobile.account"
compileSdkVersion 16
buildToolsVersion '21.1.2'
defaultConfig{
applicationId "com.hundsun.winner"
minSdkVersion 7
versionCode 1
versionName '2.0.0'
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
//去掉第三方jar包中重复的类
packagingOptions {
// exclude 'META-INF/LICENSE.txt'
// exclude 'META-INF/LICENSE'
// exclude 'META-INF/NOTICE'
// exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/ASL2.0'
}
//签名
signingConfigs {
//你自己的keystore信息
releaseConfig {
storeFile file("foundersc.keystore")
storePassword "founderSc20151015xiaofang"
keyAlias "foundersc"
keyPassword "founderSc20151015xiaofang"
}
debugConfig {
storeFile file("foundersc.keystore")
storePassword "founderSc20151015xiaofang"
keyAlias "foundersc"
keyPassword "founderSc20151015xiaofang"
}
}
buildTypes {
release{
minifyEnabled true
// shrinkResources true//资源需要在服务端返回后动态绑定,现在不需要,我不可能在代码里预定义这个资源引用,类似这种情况可能会找不到资源文件
signingConfig signingConfigs.releaseConfig
proguardFile 'proguard.cfg'
zipAlignEnabled true
renderscriptOptimLevel 5
}
debug{
minifyEnabled false
// shrinkResources true//资源需要在服务端返回后动态绑定,现在不需要,我不可能在代码里预定义这个资源引用,类似这种情况可能会找不到资源文件
signingConfig signingConfigs.debugConfig
proguardFile 'proguard.cfg'
zipAlignEnabled true
renderscriptOptimLevel 5
}
}
lintOptions {
abortOnError false
}
dexOptions {
//incremental true
// 对于dex 的--multi-dex 选项设置与预编译的library工程有冲突,因此如果你的应用中包含引用的lirary工程,需要将预编译设置为false
//否则会抛出com.android.dex.DexException: Library dex files are not supported in multi-dex mode异常
preDexLibraries = false
//设置虚拟机堆内存空间大小,避免在编译期间OOM
javaMaxHeapSize "2g"
}
}
另外的
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.3.0'//统计应用方法数
}
}
//Error:(51, 13) Failed to resolve: org.apache.commons:commons-lang3:3.4
//缺少jar包,可以指定一个仓库下载(jcenter)
allprojects{
repositories{
jcenter()
mavenCentral()
}
}
apply plugin: 'android'
//apply plugin: 'com.getkeepsafe.dexcount'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:multidex:1.0.1'
compile(name:'pulltorefresh-lib',ext:'aar')
}
//—multi-dex:多 dex 打包的开关
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = []
}
dx.additionalParameters += '--multi-dex' // enable multidex
dx.additionalParameters +='--set-max-idx-number=48000'//用于控制每一个dex的最大方法个数,写小一点可以产生好几个dex,默认每个 dex 中方法数最大为65536
// optional
// dx.additionalParameters += "--main-dex-list=$projectDir/<filename>".toString() // enable the main-dex-list
}
}
repositories{
flatDir{
dirs 'libs'
}
}
android {
// compileSdkVersion 14
// buildToolsVersion "23.0.1"
// applicationId "com.foundersc.mobile.account"
compileSdkVersion 14
buildToolsVersion '22.0.1'
defaultConfig{
applicationId "com.hundsun.winner"
minSdkVersion 14
versionCode 1
versionName '2.0.0'
multiDexEnabled true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
//去掉第三方jar包中重复的类
packagingOptions {
// exclude 'META-INF/LICENSE.txt'
// exclude 'META-INF/LICENSE'
// exclude 'META-INF/NOTICE'
// exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/ASL2.0'
}
//签名
signingConfigs {
//你自己的keystore信息
releaseConfig {
storeFile file("wf.keystore")
storePassword "123456"
keyAlias "wfwf"
keyPassword "654321"
}
debugConfig {
storeFile file("wf.keystore")
storePassword "123456"
keyAlias "wfwf"
keyPassword "654321"
}
}
buildTypes {
release{
minifyEnabled true
// shrinkResources true//资源需要在服务端返回后动态绑定,现在不需要,我不可能在代码里预定义这个资源引用,类似这种情况可能会找不到资源文件
signingConfig signingConfigs.releaseConfig
proguardFile 'proguard.cfg'
zipAlignEnabled true
renderscriptOptimLevel 5
}
debug{
minifyEnabled false
// shrinkResources true//资源需要在服务端返回后动态绑定,现在不需要,我不可能在代码里预定义这个资源引用,类似这种情况可能会找不到资源文件
signingConfig signingConfigs.debugConfig
proguardFile 'proguard.cfg'
zipAlignEnabled true
renderscriptOptimLevel 5
}
}
lintOptions {
abortOnError false
}
dexOptions {
//incremental true
// 对于dex 的--multi-dex 选项设置与预编译的library工程有冲突,因此如果你的应用中包含引用的lirary工程,需要将预编译设置为false
//否则会抛出com.android.dex.DexException: Library dex files are not supported in multi-dex mode异常
preDexLibraries = false
//设置虚拟机堆内存空间大小,避免在编译期间OOM
javaMaxHeapSize "2g"
}
}
gradle大体内容的更多相关文章
- 深入理解Android之Gradle
深入理解Android之Gradle 格式更加精美的PDF版请到:http://vdisk.weibo.com/s/z68f8l0xTYrZt 下载 Gradle是当前非常"劲爆" ...
- Gradle史上最详细解析
转自:https://www.cnblogs.com/wxishang1991/p/5532006.html 郑重申明本文转自邓凡平老师的 http://www.infoq.com/cn/articl ...
- Gradle详细解析***
前言 对于Android工程师来说编译/打包等问题立即就成痛点了.一个APP有多个版本,Release版.Debug版.Test版.甚至针对不同APP Store都有不同的版本.在以前ROM的环境下, ...
- AndroidStudio配置gradle,让App自动签名
最近开发关于微信一系列功能,发现分享.支付必须要打包签名才能测试,太耽误事了,耗时耗力...在网上扒拉扒拉资料,发现有很多前辈都处理过类似问题,非常感谢大家的分享,参考链接:http://blog.c ...
- android gradle的全局管理
转自:https://github.com/stormzhang 工程目录下建立baseConfig.gradle文件 内容如下 ext { android = [compileSdkVersion: ...
- Android 开发必备知识:我和 Gradle 有个约会
腾讯Bugly特约作者:霍丙乾 0.讲个故事 0.1 Ant,我还真以为你是只蚂蚁 真正开始近距离接触编程其实是在2012年,年底的时候带我的大哥说,咱们这个 app 发布的时候手动构建耗时太久,研究 ...
- 外包采用Gradle生成多套app打包
目的:可修改app名称.icon.包名.接口地址及其它 一. 修改基本配置(包名.版本号等) 配置module下的build.gradle 添加productFlavors例如: produ ...
- 十分钟理解Gradle
一.什么是Gradle 简单的说,Gradle是一个构建工具,它是用来帮助我们构建app的,构建包括编译.打包等过程.我们可以为Gradle指定构建规则,然后它就会根据我们的“命令”自动为我们构建ap ...
- Android Studio系列教程五--Gradle命令详解与导入第三方包
Android Studio系列教程五--Gradle命令详解与导入第三方包 2015 年 01 月 05 日 DevTools 本文为个人原创,欢迎转载,但请务必在明显位置注明出处!http://s ...
随机推荐
- iOS开发UI篇—控制器的View的创建
iOS开发UI篇—控制器的View的创建 一.6种创建控制器View的方式 #import "NJAppDelegate.h" #import "NJViewContro ...
- python and django
[安装(CentOS 6.5)] 安装python, 采用yum install python,安装后为2.6版本 安装django 1.6.4,再高的版本,就需要python提升版本.下载并解压,然 ...
- 获取数据库里面最新的ID
你如果新插入的一段资料,你想获取它的ID,就用 “mysql_insert_id()”; 并且要重新定义一个名称
- qq快速聊天
和女朋友聊天的时候,每次发完消息我都习惯性把聊天界面关了,或者我想找女朋友聊天了,又要打开主界面再打开聊天窗口 每次感觉特别麻烦.所以我在想有没有一个好的办法直接打开聊天窗口的.刚好这两天又在写jav ...
- 黑马程序员——OC语言 其他语法
Java培训.Android培训.iOS培训..Net培训.期待与您交流! (以下内容是对黑马苹果入学视频的个人知识点总结) (一)ARC的判断准则:只要没有强指针指向对象,就会释放对象 1.ARC特 ...
- mysql主从复制配置(精简版)
一.首先准备两台服务器,虚拟机即可,以笔者为例:master:192.168.1.105 slave:192.168.1.106 二.保证两台虚拟机能相互ping通,先把防火墙关闭:service i ...
- 团队开发——冲刺1.e
冲刺阶段一(第五天) 冲刺阶段一(第五天) 1.昨天做了什么?优化界面细节. 查看C#资料,再解决自己电脑的问题. 2.今天准备做什么? 为解决自己电脑的问题,查找关于C#的资料,后期做准备.
- PATH变量
PATH变量由系统管理员配置,通常包含如下一些存储系统程序的标准路径: /bin 二进制文件目录,用于存放启动系统时用到的路径 /usr/bin 用户二进制文件目录,用于存放用户使用的标准程序 / ...
- chrome49 新特性 chrome.org转载
Transitioning from SPDY to HTTP/2 Thursday, February 11, 2016 Last year we announced our intent to e ...
- sublime福音:微信小程序组件及API补全插件
微信自带的编辑器操作起来各种不顺手,调试的时候需要用到,但是编辑的时候还是用自己熟悉的编辑器好一点. 将文件目录导入到sublime,在sublime编辑保存后,回到小程序开发工具刷新页面即可. 下面 ...