Debug gradle on android studio
Create debugger
Run->Edit Configurations
Add New Configuration
Add Remote configuration
Open debug mode
$ export GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
Start debugger
$ ./gradlew someTask -Dorg.gradle.daemon=false #!important, disable daemon mode
Attach debugger
Set breakpoints
Start debug
Disable debug mode
$ unset GRADLE_OPTS