Claude-skill-registry android-gradle
Automate Gradle tasks for Android projects - build, test, coverage, clean. Use when building APKs, running unit tests, generating coverage reports, or checking dependencies.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/android-gradle" ~/.claude/skills/majiayu000-claude-skill-registry-android-gradle && rm -rf "$T"
manifest:
skills/data/android-gradle/SKILL.mdsource content
Android Gradle Skill
Automate Gradle tasks for Android projects: build, test, coverage, clean.
When to Use
- Building debug/release APK
- Running unit tests
- Generating coverage reports
- Cleaning build cache
- Checking dependencies
Commands
Build Commands
| Command | Description | Gradle Task |
|---|---|---|
| Build debug APK | |
| Build release APK | |
| Install to device | |
| Clean build cache | |
| Clean + build | |
Test Commands
| Command | Description | Gradle Task |
|---|---|---|
| Run all unit tests | |
| Run single class | |
| Run single test | |
Coverage Commands
| Command | Description | Gradle Task |
|---|---|---|
| Full coverage report | |
| Enforce 80% minimum | |
Dependency Commands
| Command | Description | Gradle Task |
|---|---|---|
| Show dependency tree | |
| App module only | |
| Check outdated deps | |
Usage Examples
# Build and install debug APK ./gradlew assembleDebug && ./gradlew installDebug # Run specific test class ./gradlew test --tests "*.GameManagerImplTest" # Generate coverage report ./gradlew jacocoTestDebugUnitTestReport # Report at: app/build/reports/jacoco/jacocoTestDebugUnitTestReport/html/index.html # Clean rebuild ./gradlew clean assembleDebug
Timeout Configuration
| Task Type | Timeout |
|---|---|
| assembleDebug | 2 min |
| testDebugUnitTest | 3 min |
| jacocoTestDebugUnitTestReport | 2 min |
| clean | 30 sec |
| dependencies | 30 sec |
Version Compatibility
| Gradle | AGP | Kotlin | JDK |
|---|---|---|---|
| 8.10+ | 8.8+ | 2.1+ | 17+ |
| 8.5+ | 8.5+ | 2.0+ | 17+ |
| 8.0+ | 8.0+ | 1.9+ | 17+ |
Error Handling
// Handle build failures in scripts fun handleGradleResult(exitCode: Int, output: String) { when { exitCode != 0 && output.contains("Compilation failed") -> println("Fix compilation errors in: ${extractErrorFiles(output)}") exitCode != 0 && output.contains("AAPT") -> println("Resource error - check XML files") exitCode != 0 && output.contains("OutOfMemoryError") -> println("Increase heap: org.gradle.jvmargs=-Xmx4g") } }
Common Errors:
- Build failure: Parse error message, check file:line references
- Test failure: Run with
for stack traces--info - Coverage below threshold: Check
app/build/reports/jacoco/*/html/index.html - OOM: Increase heap in
gradle.properties
Test Result Validation
# Run tests and validate results ./gradlew testDebugUnitTest && echo "✓ All tests passed" || echo "✗ Tests failed" # Check coverage threshold ./gradlew jacocoTestDebugUnitTestReport # Verify: app/build/reports/jacoco/jacocoTestDebugUnitTestReport/html/index.html # Target: 80%+ line coverage # Parse test results programmatically cat app/build/test-results/testDebugUnitTest/*.xml | grep -E "(tests=|failures=)"
Troubleshooting
| Issue | Solution |
|---|---|
| Build hangs | Kill daemon: |
| Cache issues | Clean: |
| OOM errors | Add to gradle.properties: |
| Version conflict | Force resolution in build.gradle.kts |
| Slow builds | Enable: |
Command Workflows
# Full CI workflow ./gradlew clean testDebugUnitTest jacocoTestDebugUnitTestReport assembleDebug # Quick iteration ./gradlew assembleDebug -x lint -x test && ./gradlew installDebug # Pre-commit check ./gradlew ktlintCheck testDebugUnitTest
CI/CD Integration
# GitHub Actions example - name: Build & Test run: | ./gradlew testDebugUnitTest ./gradlew jacocoTestDebugUnitTestReport ./gradlew assembleDebug - name: Upload Coverage uses: codecov/codecov-action@v4 with: files: app/build/reports/jacoco/*/jacoco*.xml
Best Practices
- Always use Gradle wrapper (
), never system Gradle./gradlew - Use
for multi-module projects--parallel - Enable configuration cache for faster builds
- Skip lint with
if not needed for quick iterations-x lint