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. Eucalyptus-NC管理

    1.前言 Elastic Utility Computing Architecture for Linking Your Programs To Useful Systems (Eucalyptus) ...

  2. repair table

    mysql> show create table lixl;+-------+---------------------------------------------------------- ...

  3. jQuery_1_基础核心

    jQuery代码风格:在jQuery程序中,不管是页面元素的选择还是内置的功能函数,都是以“$"来起始的. $(function(){});                        / ...

  4. c++ STL stack容器成员函数

    这是后进先出的栈,成员函数比较简单,因为只能操作栈顶的元素.不提供清除什么的函数. 函数 描述 bool s.empty() 栈是否为空(即size=0).若空,返回true,否则,false. vo ...

  5. java Vamei快速教程05 实施接口

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 在封装与接口中,private关键字封装了对象的内部成员.经过封装,产品隐藏了内部 ...

  6. Bezier贝塞尔曲线的原理、二次贝塞尔曲线的实现

    Bezier曲线的原理 Bezier曲线是应用于二维图形的曲线.曲线由顶点和控制点组成,通过改变控制点坐标可以改变曲线的形状. 一次Bezier曲线公式: 一次Bezier曲线是由P0至P1的连续点, ...

  7. fmt - 简易的文本格式优化工具 simple optimal text formatter

    总览 (SYNOPSIS) ../src/fmt [-DIGITS] [OPTION]... [FILE]... 描述 (DESCRIPTION) 重新 格式化 文件 FILE(s) 中的 每一个 段 ...

  8. 说说qwerty、dvorak、colemak三种键盘布局

    [qwerty布局] qwerty布局大家应该都很熟悉了,全世界最普及的键盘布局. 截止到去年接触并使用dvorak布局之前,我使用了十几年qwerty布局,在http://speedtest.10f ...

  9. spring mvc + swagger 配置

    首先,添加mvc框架(略)以及Swagger Maven依赖: <dependency> <groupId>io.springfox</groupId> <a ...

  10. cuda流测试=basic_single_stream

    cuda流测试 /* * Copyright 1993-2010 NVIDIA Corporation. All rights reserved. * * NVIDIA Corporation and ...