Debugging Gradle build files in Intellij / Android Studio
You can't debug Gradle files. We may someday implement this, as it would obviously be a great thing, but it's a long ways off. We're in the process of adding more intelligence about syntax highlighting and analysis of build files. Well, actually, JetBrains is adding it to IntelliJ and we're picking it up. This will get better over the coming weeks and months.
Original source
1. Create a debugger
- Run -> Edit Configurations
- Add New Configuration
- Add Remote configuration
2. Open debug mode
$ export GRADLE_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
3. Start debugger
$ ./gradlew someTask -Dorg.gradle.daemon=false #!important, disable daemon mode
4. Attach debugger
- Set breakpoints
- Start debug
5. Disable debug mode
$ unset GRADLE_OPTS