Gradle Commander
Expert instructions for managing Android builds using Gradle.
SKILL.md.claude/skills/gradle_commander/SKILL.md
GitHubGradle Commander
This skill provides expertise in interacting with the Gradle build system for Android projects.
Core Principles
- Always use the Wrapper: Use
./gradlew(orgradlew.baton Windows) instead of a system-installedgradlebinary to ensure version consistency. - Clean Builds: When facing inexplicable build errors, running a clean task often helps.
- Parallel Execution: Gradle runs tasks in parallel by default; be aware of potential race conditions in custom tasks.
Common Commands
1. Building the APK
To build the debug APK:
./gradlew assembleDebug
To build the release APK (requires signing config):
./gradlew assembleRelease
2. Installation
To build and install the debug APK onto a connected device:
./gradlew installDebug
3. Cleaning
To remove the build directory:
./gradlew clean
4. Running Tests
Unit tests:
./gradlew testDebugUnitTest
Android Instrumentation tests:
./gradlew connectedDebugAndroidTest
5. Dependency Analysis
To see the dependency tree for the app module (debug variant):
./gradlew app:dependencies --configuration debugCompileClasspath
Troubleshooting Build Errors
- Read the Output: Scroll up from the "Build Failed" message. The actual error is often hidden amidst warnings.
- Stacktrace: If the error is vague, run with
--stacktrace(e.g.,./gradlew assembleDebug --stacktrace). - Info/Debug: For deeper inspection, use
--infoor--debug.