9

There are some other related questions in this same website, but I just cannot get my head around this.

In their website they're extremelly abstract.

Gradle is build automation evolved. Gradle can automate the building, testing, publishing, deployment and more of software packages or other types of projects such as generated static websites, generated documentation or indeed anything else.

What does that really mean? Thanks

frankelot
  • 13,666
  • 16
  • 54
  • 89
  • It basically helps automate all of the processes that it can. Helps makes it so you can focus your time on your code (as long as you have configured your gradle build correctly) – zgc7009 May 22 '14 at 19:48
  • 3
    possible duplicate of [What is Gradle in android studio?](http://stackoverflow.com/questions/16754643/what-is-gradle-in-android-studio) – Aneesh Dec 23 '14 at 06:41

3 Answers3

7

Gradle is software for building software.

Let's assume for the moment, given in your question, that you are working on an Android app.

You may be using Eclipse to develop your app. Eclipse, as part of that, will use its own build automation engine to compile your Java, cross-compile the bytecode into Dalvik bytecode, compile the resources and manifest, package all that up into an APK, sign it with a signing key, and zipalign the results (among other steps).

Instead (or in addition to) Eclipse, you might have used android update project to generate a build.xml file, one that allows your app to be built via Apache Ant. Ant, like Gradle, is a build automation engine -- software for building software. Gradle happens to be newer and more powerful than Ant, but they have the same basic role in our lives: taking all stuff we type in (like, say, Java source) and get an APK out as a result.

If you have used Maven for project builds, or have used other IDEs (e.g., IntelliJ IDEA, NetBeans), you have used their build automation engines as part and parcel of that work.

Gradle is not only available for command-line builds as a replacement for Ant, but it is also the build automation engine used (by default) in Android Studio. Quoting the Android developer documentation:

The Android Studio build system consists of an Android plugin for Gradle. Gradle is an advanced build toolkit that manages dependencies and allows you to define custom build logic. Many software projects use Gradle to manage their builds. The Android plugin for Gradle does not depend on Android Studio, although Android Studio is fully integrated with it. This means that:

  • You can build your Android apps from the command line on your machine or on machines where Android Studio is not installed (such as continuous integration servers).
  • You can build your Android apps from Android Studio with the same custom build configuration and logic as when you build from the command line.

The output of the build is the same whether you are building a project from the command line, on a remote machine, or using Android Studio.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @feresr: "I thought the compiler was in charnge of converting my code and turn it into Dalvik bytecode, also would compile my resources and manifest" -- most likely, you are not running **`javac`** by hand. You are certainly more than welcome to do so. Otherwise, what is telling **`javac`** what to compile (and how) is the build automation engine. "what else am I gonna depend on to build Android Applications" -- libraries written by other developers, for example. – CommonsWare May 22 '14 at 20:04
  • @feresr: Libraries often depend upon other libraries, and tracking down all the nested dependencies can be a challenge. In the specific case of Gradle for Android, we also can start using AARs, which are basically compiled Android library projects (source, resources, etc.), and dependency networks of those. Whether you as a developer wish to take advantage of any of that is up to you. – CommonsWare May 22 '14 at 20:12
  • @feresr: "Also, android studio will call javac when I execute the project." -- no, it does not. Android Studio invokes Gradle, which in turn invokes **`javac`**. – CommonsWare May 22 '14 at 20:12
  • @feresr: I haven't used it, but based on the site's description, Composer is a dependency manager for PHP. Gradle, Maven, rubygems, bower, and various other systems also offer dependency management for various development languages and environments, and I am sure that there are dozens more. – CommonsWare May 22 '14 at 20:15
  • Thanks, you seem to really know your stuff. Could you recommend an android book? or something that helps me get started faster, I've been working on android for at least a year, and still have trouble with basic stuff like app architecture or what class to use for a specific purpose. I consider myself a decent programmer in many languages but for some reason Android is very hard to learn, it's overwhelming to new comers. – frankelot May 22 '14 at 20:36
  • 2
    @feresr: "Could you recommend an android book?" -- well, I'm biased. [I like mine](http://commonsware.com/Android). :-) – CommonsWare May 22 '14 at 20:46
0

It's a file with a set of instructions on how to compile your project. What dependencies it needs, where they are etc. You can also use it to make different versions of the project by compiling in different ways, for debugging, testing etc.

yedidyak
  • 1,964
  • 13
  • 26
0

Also you can review the answers to this post . It contains detailed explanations (By the way, I am also very new to this topic).

When we build/rebuild our project, or press run, or press debug in Android Studio, Gradle collects everything in our project (codes, resources, drawables, third party packages, etc) and compiles them into a installable file, aka APK (in the "app\build\outputs\apk\debug" folder). And then we can install it on a mobile device or run in Android Studio virtual device emulators.

If our project is not very complex, most probably we don't need to worry about Gradle. When we add new project or import external JARs, Android Studio automatically updates necessary gradle files. These files contains configuration scripts for build system, written in a language named DSL.

Gultekin
  • 119
  • 1
  • 3