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大体内容的更多相关文章

  1. 深入理解Android之Gradle

    深入理解Android之Gradle 格式更加精美的PDF版请到:http://vdisk.weibo.com/s/z68f8l0xTYrZt 下载 Gradle是当前非常"劲爆" ...

  2. Gradle史上最详细解析

    转自:https://www.cnblogs.com/wxishang1991/p/5532006.html 郑重申明本文转自邓凡平老师的 http://www.infoq.com/cn/articl ...

  3. Gradle详细解析***

    前言 对于Android工程师来说编译/打包等问题立即就成痛点了.一个APP有多个版本,Release版.Debug版.Test版.甚至针对不同APP Store都有不同的版本.在以前ROM的环境下, ...

  4. AndroidStudio配置gradle,让App自动签名

    最近开发关于微信一系列功能,发现分享.支付必须要打包签名才能测试,太耽误事了,耗时耗力...在网上扒拉扒拉资料,发现有很多前辈都处理过类似问题,非常感谢大家的分享,参考链接:http://blog.c ...

  5. android gradle的全局管理

    转自:https://github.com/stormzhang 工程目录下建立baseConfig.gradle文件 内容如下 ext { android = [compileSdkVersion: ...

  6. Android 开发必备知识:我和 Gradle 有个约会

    腾讯Bugly特约作者:霍丙乾 0.讲个故事 0.1 Ant,我还真以为你是只蚂蚁 真正开始近距离接触编程其实是在2012年,年底的时候带我的大哥说,咱们这个 app 发布的时候手动构建耗时太久,研究 ...

  7. 外包采用Gradle生成多套app打包

    目的:可修改app名称.icon.包名.接口地址及其它 一.      修改基本配置(包名.版本号等) 配置module下的build.gradle 添加productFlavors例如: produ ...

  8. 十分钟理解Gradle

    一.什么是Gradle 简单的说,Gradle是一个构建工具,它是用来帮助我们构建app的,构建包括编译.打包等过程.我们可以为Gradle指定构建规则,然后它就会根据我们的“命令”自动为我们构建ap ...

  9. Android Studio系列教程五--Gradle命令详解与导入第三方包

    Android Studio系列教程五--Gradle命令详解与导入第三方包 2015 年 01 月 05 日 DevTools 本文为个人原创,欢迎转载,但请务必在明显位置注明出处!http://s ...

随机推荐

  1. NSComparisonResul、NSNotFound、NSEnumerationOptions......的用处

    NSNotFound 定义一个值,用于指示请求项找不到或不存在.Defines a value that indicates that an item requested couldn’t be fo ...

  2. 了解Sql Server的执行计划

    前一篇总结了Sql Server Profiler,它主要用来监控数据库,并跟踪生成的sql语句.但是只拿到生成的sql语句没有什么用,我们可以利用这些sql语句,然后结合执行计划来分析sql语句的性 ...

  3. 与您共享Linux Kernel 4.8分支首个维护版本

    导读 Linux Kernel 4.8正式版于10月2日由Linus Torvalds发布,带来了包括AMDGPU OverDrive支持.NVIDIA Pascal支持.AMDGPU PowerPl ...

  4. pwnable.kr-bof

    .Nana told me that buffer overflow is one of the most common software vulnerability. Is that true? D ...

  5. STL模板之_map,stack(计算矩阵相乘的次数)

    #include <map>#include <stack>#include <iostream>using namespace std; struct Node ...

  6. 2014年4月份第3周51Aspx源码发布详情

    WPY净水机网站源码  2014-4-14 [VS2008]源码描述: 实现产品展示,在线留言,信息发布,在线咨询,营销网络地图. 网站基本管理:网站banner管理 管理首页滚动图片信息 网站右下部 ...

  7. sqlserver数据库学习(-)数据类型

    ecimal 数据类型最多可存储 38 个数字,所有数字都能够放到小数点的右边.decimal 数据类型存储了一个准确(精确)的数字表达法:不存储值的近似值. 定义 decimal 的列.变量和参数的 ...

  8. 设置类型Double小数点位数

    Double amount = 100;DecimalFormat dcmFmt = new DecimalFormat("0.0000"); String amountStr = ...

  9. C#中的IntPtr类型

    本文转自:http://zhidao.baidu.com/question/22825956.html 问: c#中无法将类型“int”隐式转换为“System.IntPtr” 这个是我引用了一个ap ...

  10. 安装生物信息学软件-Samtools

    装完Bowtie2,官方文档给出的栗子说可以玩一玩samtools,所以我入个坑 参考这篇http://m.010lm.com/roll/2016/0620/2343389.html Step 1: ...