I have read in other answers that in IntelliJ IDEA is possible to debug gradle files.
Can I do the same thing on Android Studio? And how?
EDIT: my question is not duplicate because it regards not IntelliJ but only Android Studio.
In order to debug Gradle, we have to create a new remote configuration in Android Studio.
1. Open "EditRun/Debug configurations" dialog:
Don't forget to add your breakpoint in the build.gradle
file.
2. Once in "Run/Debug Configuration" click on the +
icon to add a new configuration and then select Remote
:
As you can see on the above image I've chosen "Gradle Remote Debug".
3. Now select your "Remote" configuration in the "EditRun/Debug configurations" dialog and go to "Terminal" in Android Studio and type the following command:
./gradlew help -Dorg.gradle.debug=true --no-daemon
The above command option can be anything "help, tasks, etc." the only important attribute is -Dorg.gradle.debug=true --no-daemon
and having the "Remote" configuration setup.
After inputting the above command hit "Enter" and you'll see that the command will start the Daemon and will be listening for the remote debugger as illustrated on the following picture.
4. Now all that is left to do is to attach the debugger by clicking on the "Debug" icon in Android Studio.
Then if you haven't forgotten to set your breakpoint you'll see that Gradle will be executed and will stop at the breakpoint.
References: Debugguing Build Logic
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With