Short Answer

Gradle is a build system.

Long Answer

Before Android Studio you were using Eclipse for your development purposes. and the chance may be that you did not know how to build your android project apk without even Eclipse.

You can do this on the command line, but you have to learn what each tool (dx, aapt) does in the sdk. Eclipse saved us all from these low level but important, fundamental details by giving us their own build system.

Now, have you ever wondered why the res folder is in the same directory as your src folder?

This is where the build system enters the picture. The build system automatically takes all the source files (.java or .xml), then applies the appropriate tool (e.g, takes java class files and converts to dex format), and groups all of them into one compressed file, our beloved apk.

This build system uses some conventions: an example of one is to specify the directory containing the source files (in Eclipse it is \src folder) or resources files (in Eclipse it is \res folder).

Now, in order to automate all these tasks, there has to be a script; you can write your own build system using shell scripting in linux or batch files syntax in windows. Got it?

Gradle is another build system that takes the best features from other build systems and combines them into one**. It also learned from their shortcomings. It is JVM based build system, what that means is that you can write your own script in java, which Android Studio makes use of.

One cool thing about gradle is that it is plugin based system. This means if you have your own programming language and you want to automate the task of building some package (output like jar in case of Java) from sources then you can write a complete plugin in Java or Groovy, and distribute it to rest of world.

Why did google take it?

Google saw one of the most advanced build systems on the market and realised that you could write scripts of your own with little to no learning curve, and without learning Groovy, or any other new language. So they wrote the Android plugin for gradle.

You must have seen build.gradle file(s) in your project. That is where you can write scripts to automate your tasks. The code you saw in these files is groovy code. If you write System.out.println("Hello Gradle!"); then it will print on your console.

What can you write in script?

Simple example can be that you have to copy some files from one directory to another before the actual build process happens.

47.关于gradle的解疑的更多相关文章

  1. ionic build android error when download gradle

    这里我遇到一个问题,当用  ionic build android 的时候,无数次build,无数次失败的时候,我真想骂一句,NND的GNF,我又想起武大的臭鸡蛋,是的,该丢,发明这种东西的人,难道不 ...

  2. 在Gradle中使用jaxb的xjc插件

    jaxb,全称为Java Architecture for Xml Binding,是一种将java对象与xml建立起映射的技术.其主要提供两个功能,一是将java对象映射为xml,二是将xml映射为 ...

  3. 使用Gradle构建构建一个Java Web工程及持续集成环境Jenkins配置

    安装Eclipse插件——Buildship 什么是Buildship? Buildship能方便我们通过Eclipse IDE创建和导入Gradle工程,同时还能执行Gradle任务. Eclips ...

  4. Gradle build设置自动log开关

    应用场景 通常情况下我们的apps发布后也就是release模式下log是不显示的,debug模式下是显示log的,但是在特殊情况下我们测试release包的时候需要log的时候,就无法使用Build ...

  5. 深入理解gradle编译-Android基础篇

    深入理解gradle编译-Android基础篇 导读 Gradle基于Groovy的特定领域语言(DSL)编写的一种自动化建构工具,Groovy作为一种高级语言由Java代码实现,本文将对Gradle ...

  6. Android Studio 第一次新建Android Gradle项目超级慢的解决方案

    大家有什么问题,欢迎问我! 注:Android Studio在第一次新建一个Gradle项目时需要下载Gradle,所以启动很慢(Gradle-bin大约三十几兆),所以我们应该事先帮他下载好. 首先 ...

  7. 错误异常 (1)Android Studio错误提示:Gradle project sync failed. Basic functionality (eg. editing, debugging) will not work properly

    [已解决]Android Studio错误提示:Gradle project sync failed. Basic functionality (eg. editing, debugging) wil ...

  8. 使用gradle创建java程序

    创建一个Java项目 我们可以使用Java插件来创建一个Java项目,为了做到这点,我们需要把下面这段语句加入到build.gradle文件中: 1 apply plugin: 'java' 就是这样 ...

  9. [转]-用Gradle 构建你的android程序

    出处:http://www.cnblogs.com/youxilua  前言 android gradle 的插件终于把混淆代码的task集成进去了,加上最近,android studio 用的是gr ...

随机推荐

  1. windows 10 开启安卓模拟器蓝屏

    上周装了个vs2017 rc 本想试试 开发安卓怎么样,花了一晚上时间终于装好了. 第二天开夜神模拟器的时候蓝屏了.. 然后就逐个卸载VS2017的功能,先是卸了 自带的仿真程序,没用.然后全部卸载掉 ...

  2. Problem G: 角谷步数

    Problem G: 角谷步数 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 78  Solved: 28[Submit][Status][Web Bo ...

  3. 2018.5.29 Oracle连接到空闲例程

    解决方法如下: 1.通过cmd命令窗启动Oracle:(最好是以管理员身份启动) C:\Users\Administrator>sqlplus /nolog SQL>conn /as sy ...

  4. .net网站的下载地址

    .net4.0网址:http://www.crsky.com/soft/6959.htmlsql server r2: http://pan.baidu.com/share/link?shareid= ...

  5. 关于请求时状态为cancel

    项目中发现有一个问题,在我发送某些请求的时候请求一会状态就变为cancel了,我滴个乖乖,这是咋回事,被取消了,后来经过仔细排查后发现了以下两个问题 1.AJAX和form表单同时使用,(form提交 ...

  6. SOA架构,dubbo,Zookeeper

    1. 分析 由于项目是基于soa的架构,表现层和服务层是不同的工程.所以要实现查询需要两个系统之间进行通信. 如何实现远程通信? 1.Webservice:效率不高基于soap协议.项目中不推荐使用. ...

  7. Java面向对象之继承,方法重写,super关键字,员工类系列继承题

    在程序中,如果想声明一个类继承另一个类,需要使用extends关键字. 格式: class 子类 extends 父类 {} 继承的好处 1.继承的出现提高了代码的复用性,提高软件开发效率. 2.继承 ...

  8. AngularJS 字符串

    AngularJS字符串就像是JavaScript字符串 <!DOCTYPE html><html><head><meta http-equiv=" ...

  9. Oracle ORA-01722 无效数字

    ORA-01722 无效数字 以下几种情况,数据库会报“ORA-01722 无效数字”错误: ① 对于两个类型不一致,一个“数字类型”,一个“非数字类型”进行赋值,或者比较操作: ② to_numbe ...

  10. daemon函数实现原理 守护进程

    linux提供了daemon函数用于创建守护进程,实现原理如下: #include <unistd.h> int daemon(int nochdir, int noclose); 1.  ...