There is one very sad problem in the Android world that has a good and simple solution, so if you are an Android developer or are otherwise using Gradle as your build tools, please pay attention!
Let's imagine you arrive to work in the morning. A notification pop-up:
Application not working
Hello dear developer. One customer has reported that the application is not working since yersterday. Please fix it ASAP.
My wild guess is that you would react along those lines
What is not working? Is that a crash? Do you have a stacktrace?
Or is something not working as expected? And why? Which version of the app? On which smartphone?
Do you have reproducing steps?
Yet somehow we forget it when it comes to our builds.
Those context-free "bug reports" and tips are everywhere. I am sad when I look at StackOverflow questions tagged with "gradle, android". I am sad when I read issues in the android issue tracker. I am sad when I read all those Medium posts. Everywhere the same pattern:
(original_post) Hello, my build is slow / not working, please advice.
(original_post) Here are 2.000 probably irrelevant lines that I copy/pasted from my build.
(answer1) Copy/paste this Groovy snippet somewhere in your builds. I don't understand what it does, but that should solve your problem.
(answer2) No, that doesn't work.
Those context-less conversation are infuriating. The good news is that there is a good, simple answer for this!
Everytime you need to understand why your build is failing and ask for help, re-run the Gradle task that was failing with
--scan. For example:
To make it more convenient, you should add this setup at in your top
You will find
$VERSION at https://plugins.gradle.org/plugin/com.gradle.build-scan
Explore by yourself at https://scans.gradle.com/s/ug6vfggccmozm/
Or continue reading.
If your build fails, the stacktrace will be available as well.
Don't try anymore to decipher in your Jenkins log why your tests are failing. The Gradle Build Scan also reports which tests are failing and why:
Performance metrics for your build with personalised suggestion from Gradle.
Read along its companion manual
Some would answer: "Because you didn't RTFM?".
But what I find interesting about RTFM is that it has two, quite different meanings: Read The Fucking Manual and Read The Friendly Manual.
The "Configure your build" section on the Android official website is really terrible and I'm not surprised you didn't know about the Gradle Build Scan if that is what you rely on.
And that's perhaps the best part of using the Gradle Build Scan: it provides direct links to the relevant parts of the official documentation from Gradle which are more of the Friendly Manual kind.
See it yourself: https://scans.gradle.com/s/ug6vfggccmozm#switches