gradle其他优点不说,在android当应用程序公布。假设你要算一些渠道,gradle 在节目包装散装优势;下面给大家介绍的图形
按eclipse当出口 选择Android;例如下面的附图 一步一步往下点
-
欢迎增加QQ交流3群:317874559
点击完毕之后 project里面就生成了例如以下的几个文件。也就是gradle的配置文件
打开gradle-wrapper.properties这个文件。能够看到distributionUrl这个地址;而这个地址就是gradle的下载地址。在浏览器打开下载 例如以下图:
将下载的文件押解出来;然后须要设置系统环境变量;须要设置变量名:GRADLE_HOME变量值为:C:\xiong\gradle-1.10-all\gradle-1.10(也就是你下载的Gradle文件的根文件夹)然后设置path。在后面加上C:\xiong\gradle-1.10-all\gradle-1.10\bin 例如以下图
然后执行在cmd中执行gradle -v来推断是否设置成功 例如以下图
确定成功安装之后就基本能够执行gradle命令来打包了;将cmd命令定位到project的根文件夹,然后执行gradle bulid
例如以下图
假设须要批量打包;则在build.gradle进行配置
原始eclipse生成的文件内容例如以下
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' } } apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') } android { compileSdkVersion 19 buildToolsVersion "19.0.3" 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') } }仅仅要在如上代码中加入就能够 比方
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' } } apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') } android { compileSdkVersion 19 buildToolsVersion "19.0.3" 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') //批量打包--指定配置文件 //不同的渠道商相应的各自AndroidManifest //AndroidManifest的application标签仅仅用配置渠道号的值 //其它公共配置都放在公共的AndroidManifest.xml中 one { manifest.srcFile 'tests/AndroidManifest1.xml' } two { manifest.srcFile 'tests/AndroidManifest2.xml' } instrumentTest.setRoot('tests') } //批量打包--声明 productFlavors { one { //这里能够配置不同的包名 } two { } } //签名 signingConfigs { myConfig { storeFile file("11.keystore") //签名文件 storePassword "111111" keyAlias "111111" keyPassword "111111" //签名password } } }
例如以下图
至于其它的 俺就不说了 不动找度娘
转载请注明出处:http://blog.csdn.net/x605940745
版权声明:本文博客原创文章,博客,未经同意,不得转载。
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/4726298.html,如需转载请自行联系原作者