Newbie question to how gradle works


#1

Hello all:

Please forgive my newbie ignorance and my newbie question.

I come from a C++/Makfile world on Linux.

I am recently undertaking a new project for Android that uses gradle with Android Studio. I am new to gradle and to Android.

I am trying to understand how an Android project gets compiled. There are only 3 .gradle files in the entire project:

./build.gradle
./app/build.gradle
./settings.gradle

I have a simple question. I cannot find in any of the gradle files above any rules/tasks that define

  • how .java files get compiled into a .class file.
  • how .class files get assembled into a .jar file
  • how the .apk file gets assembled

I cannot trace through the script to understand what happens when I do “gradle assemble”.

Are all those tasks/rules defined for me implicitly ?

Thanks
Richard


(Stefan Oehme) #2

Hi Richard,

these tasks are defined as part of the Android plugin that your project is using. This is one of the big strengths of Gradle: Plugin developers can abstract a certain domain to offer a higher-level language to their users. You’ve probably seen the android {} block in your build script. The Android plugin creates all the necessary tasks to build your project based on the configuration you specify in this block.

Cheers,
Stefan