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. WCF初探-23:WCF中使用Message类(下)

    前言 在上一篇WCF中使用Message类(上)中,文章介绍了WCF中使用Message类的基本知识和怎样创建消息,本文是承接上一篇文章,如果想要更好的阅读本文,请先阅读上一篇文章.在这篇文章中,我将 ...

  2. iOS开发UI篇—UIScrollView控件介绍

    iOS开发UI篇—UIScrollView控件介绍 一.知识点简单介绍 1.UIScrollView控件是什么? (1)移动设备的屏幕⼤大⼩小是极其有限的,因此直接展⽰示在⽤用户眼前的内容也相当有限 ...

  3. require.js的使用

    RequireJS是一个非常小巧的JavaScript模块载入框架,是AMD规范最好的实现者之一.最新版本的RequireJS压缩后只有14K,堪称非常轻量.它还同时可以和其他的框架协同工作,使用Re ...

  4. AspNetPager分页

    1.页面部分 <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefi ...

  5. JavaWeb chapter6 对象作用域

    1.  对象属性所在作用域:谁能看到并使用这个属性,以及它能存活多久. 2.  应用上下文ServletContext对象作用域: 对于整个Web应用,只有一个ServletContext对象,而且在 ...

  6. 一块神奇的树莓派电子板竟让我学会了Linux系统

    树莓派(Raspberry Pi)是基于ARM的微型电脑主板,外形只有信用卡大小,因此也被称为新型卡片式电脑,树莓派具有电脑的所有基本功能,可谓麻雀虽小五脏俱全.而其开发组织Raspberry Pi ...

  7. Appcan 3.2 Switch操作

    Appcan3.0,有了很多不错的东西,但官方的文档还是那么的不靠谱. 我将记录下,我学习到的东西. 显示2个switch <div class="ub ub-pe"> ...

  8. 【转】Mybatis 3.1中 Mapper XML 文件 的学习详解

    MyBatis 真正的力量是在映射语句中.这里是奇迹发生的地方.对于所有的力量,SQL 映射的 XML 文件是相当的简单.当然如果你将它们和对等功能的 JDBC 代码来比较,你会发现映射文件节省了大约 ...

  9. Spring配置中的classpath和classpath*的区别

    初学SSH框架,昨天在配置Spring的时候,提示我找不到Spring.xml文件,后面百度之后把classpath改成classpath* 就好了,下面是了解到的简单区别. classpath:只会 ...

  10. mysql 日期类型比较

    MySQL 日期类型:日期格式.所占存储空间.日期范围 比较. 日期类型        存储空间       日期格式                 日期范围 ------------ ------ ...