Free Shipping

Secure Payment

easy returns

24/7 support

  • Home
  • Blog
  • Introduction of Gradle in Android

Introduction of Gradle in Android

 July 13  | 0 Comments

Gradle is a build tool with a focus on whole project automation and support for a multi-language development. It was created in 2008.

It was implemented in Java and it is very popular because of its opensource compatibility.

Before we started using Android Studio, we have used Eclipse for Android app development purpose.

The gradle build system is designed to support complex scenarios while creating Android applications like :

  1. Multi-distribution : The application must be customized for multiple clients
  2. Multi-application : Supporting the creation of multiple APKs for different devices while reusing the code.

While running any applicaiton, it triggers the appropriate Gradle task for for that particular application and starts the applicaiton after building of Gradle.


The Android Studio plug-ins allows Gradle tasks to be initiated and managed from within the Android Studio. The Gradle command-line wrapper can be used to build Android Studio based projects.


Example in RealTime

Example : A module within Android Studio project which triggers an intent to load another module in the project. The first module is dependent on the second module since the application will fail to build if the second module cannot be located and launched at runtime.

This dependency can be declared in the file for the first module so the second module is included in the application build.

Other example of dependencies are libraries and JAR files on which the project depends in order to compile and run.

Classes & Methods

There are two types of Gradle files in your application : for Project and for particular Module.




Shortcut for Update Gradle

If you update any gradle files, it is recommended to sync project with Gradle file option.



Another functionality of Gradle is that of dependencies.

You can add library files and compile them for dependencies. Here the compile of testing number has been given to junit version name as ‘junit:junit:4.12’. You can compile your project applicaiton using v4 and v7 with their verisons.



Adding Project Dependencies

1. If you want to use user interface to fill out the dependcies, you can choose do the following :

a) Right click on the module(app)

b) Choose Open Module Settings


2. The Dialog Box will open as below:


3. Choose Dependenices Tab from above Tabs.


4. Now to add a dependencies, Simply click on + Button.


5. Let’s click on any dependency you want to add dependency. For example, here I am adding Joda Time dependency.


6. If you click on OK the dependency will be added like below:

Note : Remember to always Sync Project with Gradle Files to kick off the build.

Support libraries : v4 and v7

V4 library : This library is designed to be used with Android 1.6 and higher. It includes the largest set of APIs compared to the other libraries, including support for application components, user interface features, accessibility, data handling, network connectivity, and programming utilities.

App Components :

  1. Fragments
  2. NotificationCompat
  3. LocalBroadcastManager

V7 library : There are several libraries designed to be used with Android 2.1 and higher. These libraries provide specific feature sets and can be included in your application independently from others.

App Components :

  1. ActionBar
  2. AppCompatActivity
  3. AppCompatDialog
  4. ShareActionProvider


For the most part, Android Studio performs application builds in the background without any intervention from the developers. This build process is handled using the Gradle system, an automated build toolkit designed to allow the ways in which projects are build to be configured and managed through a set of build configuration files.

Gradle builds system and configuration files within the context of an Android Studio project.

Hope this blog was informative enough on the Introduction to Gradle in Android.

About the Author

Hitesh Patel, currently working at AcadGild has two years of solid professional experience in designing

and developing Android applications to his credit. He is an expert in Android app development

using Eclipse IDE, Android Studio, Java, Web Services (JSON, XML), SQLite, Android SDK, and ADT plug-in.

He is proficient in common Android framework APIs (Telephony, Location, Maps, GCM) and is passionate about explaining it to others. He is an active blogger and has several projects developed by him in his bag.

Feel free to contact him at in case you have any query.