Android Studio’s interface doesn’t include a STOP button to cancel the compilation. If you have ever pressed the “Build & Run” button for a large project, you’ll know what I’m talking about. The pain is real.
For smaller projects, this isn’t really a big deal. They usually compile within a few seconds. If, however, you are working on a large project which takes more than a few minutes to compile, the compilation time can be a huge annoyance.
Luckily we have Gradle to save the day!
You can use Gradle’s command line option
--stop in the project folder to stop your Android project compilation.
First, click on the Terminal icon on the bottom bar on Android Studio. While the compilation is ongoing, type the following and press Enter.
This will stop the compilation with the following message:
Failed to complete Gradle execution. Cause: Gradle build daemon has been stopped: stop command received