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. Windows Store App 旋转中心

    旋转中心的位置可以通过设置CenterOfRotationX.CenterOfRotationY和CenterOfRotationZ属性来指定.CenterOfRotationX和CenterOfRo ...

  2. OC语言构造方法

    OC语言构造方法 一.构造方法 (一)构造方法的调用 完整的创建一个可用的对象:Person *p=[Person new]; New方法的内部会分别调用两个方法来完成2件事情,1)使用alloc方法 ...

  3. HTML5适合移动应用开发的几大特性

    1.离线缓存为HTML5开发移动应用提供了基础 HTML5 Web Storage API可以看做是加强版的cookie,不受数据大小限制,有更好的弹性以及架构,可以将数据写入到本机的ROM中,还可以 ...

  4. 循环打印i值(面试题)

    /* * 下面的代码,为了实现每隔1秒说一句话, * 找出存在的问题,并改正,然后描述一下你的解决方案. * */ var arr = [ '第一句话', '第二句话', '第三句话', '第四句话' ...

  5. redis linux 安装及jedis连接测试

    一.安装配置 1:下载redis下载地址 http://code.google.com/p/redis/downloads/list推荐下载redis-1.2.6.tar.gz,之前这个版本同事已经有 ...

  6. having()方法设置查询条件,where()设置查询条件

    having  和 where区别 ① 使用有先后顺序 ② where  price>100     having price>100 ③ where  设置条件,字段必须是数据表中存在的 ...

  7. SOA的概念

    面向服务的体系结构(service-oriented architecture,SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)通过这些服务之间定义良好的接口和契约联系起来.接口是采用中 ...

  8. tensorflow2

    # step1 加载包import tensorflow as tf import numpy as np # step2 输入:随机产生数据 # Create 100 phony x, y data ...

  9. 不让padding影响元素的宽度

    CSS3 新增了 box-sizing 属性. 以前,如果指定 div 的宽度为 div { width: 100px; height: 100px; padding: 10px; } 则包含 pad ...

  10. TCP状态变迁流程

    主动建立TCP链接情况: 被动建立TCP链接情况 主动断开链接的情况 被动断开连接的情况 在TIME_WAIT阶段需要停留2倍的MSL,MSL即Maximum Segment Lifetime,表示任 ...