学习Gradle构建Android

Android studio出来也有一段时间了,很多人都推荐,包括github上的很多工程都是gradle来构建了.应该也是未来的趋势了.

现在简单的学学Gradle总归有好处的.


来看看最简单android

 

buildscript {
       
	 repositories {
            mavenCentral()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:0.4'
        }
    }

    apply plugin: 'android'

    android {
        compileSdkVersion 17
    }

buildscript{}

Configures the build script classpath for this project. 

设置脚本的运行环境

repositories{}

Returns a handler to create repositories which are used for retrieving dependencies and uploading artifacts produced by the project. 

支持java 依赖库管理(maven/ivy),用于项目的依赖。这也是gradle 强力的地方。。。

dependencies{}

The dependency handler of this project. The returned dependency handler instance can be used for adding new dependencies. For accessing already declared dependencies, the configurations can be used. 

依赖包的定义。支持maven/ivy,远程,本地库,也支持单文件,如果前面定义了repositories{}maven 库,使用maven的依赖(我没接触过ivy。。)的时候只需要按照用类似于com.android.tools.build:gradle:0.4

gradle 就会自动的往远程库下载相应的依赖。

apply plugin:

声明构建的项目类型,这里当然是android了

android{}

设置编译android项目的参数,接下来,我们的构建android项目的所有配置都在这里完成。


参考链接:http://www.cnblogs.com/youxilua/archive/2013/05/20/3087935.html




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值