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. vue-cli建立的项目如何在手机端运行以及如何用charles来抓包

    刚开始自己在config文件夹下的index.js中的dev下的host写成的是localhost,但是发现自己不能在手机端访问,并且也不可以在charles进行抓包处理,后来把localhost改成 ...

  2. 入口类和@SpringBootApplication

    SpringBoot通常有一个名为*Application的入口类,入口类里有一个标准的Java应用的入口方法,main方法,在该方法中使用SpringApplication.run(xxxxxApp ...

  3. alias 新的命令='原命令 -选项/参数'。举例说明,alias l=‘ls -lsh' 将重新定义 ls 命令,现在只需输入 l 就可以列目录了。

    alias 新的命令='原命令 -选项/参数'.举例说明,alias l=‘ls -lsh' 将重新定义 ls 命令,现在只需输入 l 就可以列目录了.

  4. hadoop上传文件失败报错(put: Cannot create file/eclipse.desktop._COPYING_. Name node is in safe mode.)

    解决办法: 离开安全模式方法:执行以下命令即可 bin/hadoop  dfsadmin -safemode leave 若不处理安全模式的话,web服务无法启动,dfsadmin report结果异 ...

  5. 那些年,被我蠢哭了的php代码小错误~~~

    首先,我爱敲代码!!!而且我很喜欢修改bug,在看到那些bug的时候,我是兴奋的,毕竟当你解决这个bug之后感觉是很爽的. 在学习的过程中,看到无数的bug,有一些错误是很微小的,一般在PHP中都能通 ...

  6. iptables (2) 基本配置

    iptables 基本命令使用举例 一.链的基本操作 1.清除所有的规则.1)清除预设表filter中所有规则链中的规则.# iptables -F -F, --flush [chain] Flush ...

  7. 2018.6.2 AndroidStudio项目中的问题:===== oast.LENGTH_LONG和Toast.LENGTH_SHORT分别对应多长时间

    oast.LENGTH_LONG和Toast.LENGTH_SHORT分别对应多长时间 在Android源码中的NotificationManagerService.java这个类中定义了两个静态变量 ...

  8. elasticsearch RestHighLevelClient 使用方法及封装工具

    目录 EsClientRHL 更新日志 开发原因: 使用前你应该具有哪些技能 工具功能范围介绍 工具源码结构介绍 开始使用 未来规划 git地址:https://gitee.com/zxporz/ES ...

  9. Oracle小技巧_不同表空间不同用户导入导出数据dmp

    [博主注:数据库方面 ITPUB网站及博客内容非常丰富]   转载来源ITPUB 博客 经常有人会问:原来的数据在USERS表空间里面,我想把它IMP进APP表空间,我已经修改了目的用户的默认表空间, ...

  10. js日期类型date

    javascript语言核心包括Date()构造函数,用来创建表示日期和时间的函数 //返回当前的日期和时间      var today = new Date();      //2011年1月1日 ...