

Whenever you create a project in Android Studio, the build systemĪutomatically generates all the necessary Gradle build files.Here is a detailed explanation of what Gradle is and how to use it in Android Studio. What can you do in a build script?Ī simple example is that you have to copy some files from one directory to another before the actual build process happens. If you write ("Hello Gradle!") then it will print on your console. The code you saw in these files is Groovy or Kotlin code. That is where you can write scripts to automate your tasks.

You must have seen the adle or file(s) in your project. So they wrote the Android plugin for Gradle.

Google saw one of the most advanced build systems on the market and realized that you could write scripts of your own with little-to-no learning curve, and without learning Groovy or any other new language. This means if you have your own programming language and you want to automate the task of building some package (output like a JAR file for Java) from sources, then you can write a complete plugin in Java or Groovy (or Kotlin, see here), and distribute it to the rest of the world. One cool thing about Gradle is that it is a plugin-based system. That means you can write your own script in Java, which Android Studio makes use of. It is improved based off of their shortcomings. Gradle is another build system that takes the best features from other build systems and combines them into one. 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. 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). dex files), and groups all of them into one compressed file - our beloved APK. xml), then applies the appropriate tool (e.g., takes. The build system automatically takes all the source files (. This is where the build system enters the picture. Now, have you ever wondered why the res folder is in the same directory as your src folder? You can do this on the command line, but you have to learn what each tool ( dx and AAPT) does in the SDK.Įclipse saved us all from these low-level, but important, fundamental details by giving us their own build system. Before Android Studio you were using Eclipse for your development purposes, and, chances are, you didn't know how to build your Android APK without Eclipse.
