Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What commands does Android Studio's `gradle-aware make` perform

Tags:

Im playing with Android Studio & Gradle and am interesting in what gradle-aware make actually does. The reason for my interest is I was originally under the impression that the default run config for a new AS projects default gradle-aware make runs the gradle assembledebug command (looking at the status at the bottom of AS during build shows the app:assembleDebug task running) and then some install and run commands.

However in testing on a machine that has 1.9 as the installed system gradle version and a wrapper on the project set to 1.10 I get the following

  • gradle assembleDebug -> Fail : Could not create plugin of type 'AppPlugin'.
  • ./gradlew assembleDebug -> Success
  • AS Run -> Success

In my mind the above AS Run should fail if gradle-aware make was using gradle assembledebug

Looking at the src I can see the MakeBeforeRunTaskProvider.java class and the relevant commits but I cant see the relevant info

like image 249
Dori Avatar asked Mar 18 '14 12:03

Dori


People also ask

What is Gradle aware make?

Android Studio executes the Make Module command if the run/debug configuration specifies a particular module, or it executes the Make Project command if no modules are specified. Gradle-aware make. Compile the project and run Gradle. You can remove Make, it is not enabled for new projects so it's not necessary.

What is the use of Gradle in Android Studio environment?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.

What is a Buildtype in Gradle and what can you use it for?

Discussion. A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.

What is Android Gradle project?

The Android Gradle plugin (AGP) is the official build system for Android applications. It includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.


1 Answers

(have answered my own question as in writing it I sort of found the answer - but I assume if this confused me it will someone else so am posting the simple answer anyhow)

Turns out I shouldve looked in settings as you can set the gradle version that should be used - and it defaults to the "default wrapper".

Now when you create a new project in AS you have a default wrapper set up. You can if you want add a custom wrapper section to your root build.gradle of the form

task wrapper(type: Wrapper) {     gradleVersion = '1.10' } 

and then run the task with gradle wrapper to update the projects gradle wrapper (in ./gradle/). This allows the wrapper version to easily be updated.

Im assuming the "Use cusomtizable gradle wrapper" option just runs this wrapper task before any other gradle tasks (which could have a custom url for gradle zip download), whereas "use default..." will just used the last generated wrapper. This will be grayed out if the project has no generated wrapper. Please correct me if you think this is wrong.

This is using AS 0.4.6. Annoyingly there is a bug where syncing gradle files will change the project settings here - seems like to what the previous setting was as Im seeing on one project if going to "default..." and the other to "local". Time to upgrade AS!

Also AS's gradle console window shows the exact commands and output

AS gradle settings - 0.4.6

like image 107
Dori Avatar answered Oct 08 '22 02:10

Dori