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

Exception or error:

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

How to solve:

(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

Leave a Reply

Your email address will not be published. Required fields are marked *