Gradle的使用
来源:互联网 发布:诺维斯基10年数据 编辑:程序博客网 时间:2024/06/06 17:47
最近研究Android Studio打多渠道包,现总结如下:
一.Gradle最新版本2.4,下载地址: https://gradle.org/downloads/
二.Gradle官方文档教程 http://tools.android.com/tech-docs/new-build-system/user-guide
三.Gradle的安装,
1.解压下载的安装包;
2.配置变量环境 GRADLE_HOME
3.添加bin目录到path环境变量下;
4.运行gradle -v 验证是否安装好;
apply plugin: 'android'android { compileSdkVersion 21 buildToolsVersion '21.1.2' lintOptions { checkReleaseBuilds false abortOnError false } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] } // 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') } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } dependencies { compile fileTree(dir: 'libraries', include: '*.jar') compile project(':diy_common') compile project(':international_zh') } repositories { mavenCentral() maven { url "xxx" } } signingConfigs { debug { storeFile file("chenzhen.keystore") keyAlias 'chenzhen' keyPassword '162534' storePassword '162534' } release { storeFile file("chenzhen.keystore") storePassword "162534" keyAlias "chenzhen" keyPassword "162534" } } defaultConfig { testInstrumentationRunner "android.test.InstrumentationTestRunner" testHandleProfiling true testFunctionalTest true applicationId 'com.yy.only' // dex突破65535的限制 multiDexEnabled true versionCode 340 versionName '3.4' minSdkVersion 14 targetSdkVersion 21 manifestPlaceholders = [CHANNEL_NAME: "dev"] signingConfig signingConfigs.release } buildTypes { release { minifyEnabled true proguardFile 'proguard.cfg' debuggable true renderscriptDebuggable true zipAlignEnabled true proguardFile 'proguard.cfg' // 不显示Log buildConfigField "boolean", "LOG_DEBUG", "false" // 移除无用的resource文件 shrinkResources true /*applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile if (outputFile != null && outputFile.name.endsWith('.apk')) { // 输出apk名称为lock_v1.0_2015-01-15_wandoujia.apk def fileName = "lock_${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk" output.outputFile = new File(outputFile.parent, fileName) } } }*/ } debug { debuggable true renderscriptDebuggable true minifyEnabled false zipAlignEnabled false // 显示Log buildConfigField "boolean", "LOG_DEBUG", "true" } } productFlavors { channel_360 { applicationId 'com.yy.only.pro' manifestPlaceholders = [CHANNEL_NAME: "360",AUTHRORITIES: "com.yy.only.pro"] } wangdoujia { applicationId 'com.yy.only.free' manifestPlaceholders = [CHANNEL_NAME: "wangdoujia", AUTHRORITIES : "com.yy.only.free"] } } //替换渠道信息 productFlavors.all { flavor -> flavor.manifestPlaceholders = [CHANNEL_NAME: name, AUTHRORITIES:name] } //拷备so文件 task copyNativeLibs(type: Copy) { // third party lib so from(new File(projectDir, 'libs')) { include '*/*.so' } into new File(buildDir, 'native-libs') } tasks.withType(JavaCompile) { compileTask -> //noinspection all compileTask.dependsOn copyNativeLibs } //noinspection all tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask -> pkgTask.jniFolders = new HashSet<File>() pkgTask.jniFolders.add(new File(buildDir, 'native-libs')) }}
运行gradle clean
运行gradel build 即打包
或gradel assemble[release|debug|channel]buildle
0 0
- Gradle的安装使用
- Gradle的安装使用
- gradle打包的使用
- Gradle的使用
- 日积月累--Gradle的使用
- Gradle的基本使用
- Gradle的使用
- Gradle的基本使用
- gradle的使用
- Gradle的安装使用
- Gradle的使用技巧
- gradle wrapper的使用
- Gradle Task的使用
- Gradle的使用
- gradle的简单使用
- Gradle 的使用
- gradle的使用
- gradle的安装使用
- 我和opencv 2
- 好用的负margin
- 解决tabhost中的子Acitivity无法调用service的问题
- Mahout基于余弦相似度的评估
- myeclipse中提交svn时过滤.project .settings .classpath等资源文件设置
- Gradle的使用
- Artoolkit学习之一error LNK2019错误解决
- 三个小问题
- Server.CreateObject("Excel.Application")的权限问题
- pcre-8.36 编译错误 解决
- [leetcode] 67.Add Binary
- 网络资源收集
- Java类加载器
- MIT算法导论——第四讲.Quicksort