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.

16 stars

Best use case

android-gradle is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Automate Gradle tasks for Android projects - build, test, coverage, clean. Use when building APKs, running unit tests, generating coverage reports, or checking dependencies.

Teams using android-gradle should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/android-gradle/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/android-gradle/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/android-gradle/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How android-gradle Compares

Feature / Agentandroid-gradleStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Automate Gradle tasks for Android projects - build, test, coverage, clean. Use when building APKs, running unit tests, generating coverage reports, or checking dependencies.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# 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` | Build debug APK | `./gradlew assembleDebug` |
| `build:release` | Build release APK | `./gradlew assembleRelease` |
| `install` | Install to device | `./gradlew installDebug` |
| `clean` | Clean build cache | `./gradlew clean` |
| `rebuild` | Clean + build | `./gradlew clean assembleDebug` |

### Test Commands

| Command | Description | Gradle Task |
|---------|-------------|-------------|
| `test` | Run all unit tests | `./gradlew testDebugUnitTest` |
| `test:class` | Run single class | `./gradlew test --tests "*.ClassName"` |
| `test:method` | Run single test | `./gradlew test --tests "*.Class.method"` |

### Coverage Commands

| Command | Description | Gradle Task |
|---------|-------------|-------------|
| `coverage` | Full coverage report | `./gradlew jacocoTestDebugUnitTestReport` |
| `coverage:verify` | Enforce 80% minimum | `./gradlew jacocoVerification` |

### Dependency Commands

| Command | Description | Gradle Task |
|---------|-------------|-------------|
| `deps` | Show dependency tree | `./gradlew dependencies` |
| `deps:app` | App module only | `./gradlew :app:dependencies` |
| `outdated` | Check outdated deps | `./gradlew dependencyUpdates` |

## Usage Examples

```bash
# 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

```kotlin
// 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 `--info` for stack traces
- **Coverage below threshold**: Check `app/build/reports/jacoco/*/html/index.html`
- **OOM**: Increase heap in `gradle.properties`

## Test Result Validation

```bash
# 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: `./gradlew --stop` |
| Cache issues | Clean: `./gradlew clean cleanBuildCache` |
| OOM errors | Add to gradle.properties: `org.gradle.jvmargs=-Xmx4g` |
| Version conflict | Force resolution in build.gradle.kts |
| Slow builds | Enable: `org.gradle.parallel=true` |

## Command Workflows

```bash
# 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

```yaml
# 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 (`./gradlew`), never system Gradle
- Use `--parallel` for multi-module projects
- Enable configuration cache for faster builds
- Skip lint with `-x lint` if not needed for quick iterations

## References

- [Gradle User Guide](https://docs.gradle.org/current/userguide/userguide.html)
- [Android Gradle Plugin](https://developer.android.com/build)
- [JaCoCo Coverage](https://docs.gradle.org/current/userguide/jacoco_plugin.html)

Related Skills

android

16
from diegosouzapw/awesome-omni-skill

Build, review, and refactor Android mobile apps (Kotlin) using modern Android patterns. Use for tasks like setting up Gradle modules, Jetpack Compose UI, navigation, ViewModel/state management, networking (Retrofit/OkHttp), persistence (Room/DataStore), DI (Hilt/Koin), testing, performance, release builds, and Play Store readiness.

android-watch-logs

16
from diegosouzapw/awesome-omni-skill

Start real-time log streaming from connected Android device using adb logcat. Shows only app's log messages. Use when monitoring app behavior, debugging, or viewing Android logs.

android-use

16
from diegosouzapw/awesome-omni-skill

Control Android devices via ADB commands - tap, swipe, type, navigate apps

android-supabase

16
from diegosouzapw/awesome-omni-skill

Supabase integration patterns for Android - authentication, database, realtime subscriptions. Use when setting up Supabase SDK, implementing OAuth, querying database, or setting up realtime.

android-stop-app

16
from diegosouzapw/awesome-omni-skill

Stop the Android app running on connected device. Cleanly terminates the app using force-stop. Use when stopping the app for debugging, testing, or cleanup.

android-project

16
from diegosouzapw/awesome-omni-skill

Navigate and analyze Android project structure, modules, and dependencies. Use when exploring project structure, finding related files, analyzing dependencies, or locating code patterns.

android-notification-builder

16
from diegosouzapw/awesome-omni-skill

Эксперт Android notifications. Используй для push notifications, channels и notification patterns.

android-motion-specialist

16
from diegosouzapw/awesome-omni-skill

Expert Android developer for the Motion Detector project. Use this skill when working on Camera2 API integration, motion detection algorithms, Android networking (LAN sockets + Supabase Realtime), debugging crashes, or any Android/Kotlin development tasks specific to this sprint timing application.

android-kotlin

16
from diegosouzapw/awesome-omni-skill

Android Kotlin development with Coroutines, Jetpack Compose, Hilt, and MockK testing

android-kotlin-development

16
from diegosouzapw/awesome-omni-skill

Develop native Android apps with Kotlin. Covers MVVM with Jetpack, Compose for modern UI, Retrofit for API calls, Room for local storage, and navigation architecture.

android-keystore-generation

16
from diegosouzapw/awesome-omni-skill

Generate production and local development keystores for Android release signing

android-firebase

16
from diegosouzapw/awesome-omni-skill

Firebase integration patterns for Android - Crashlytics, Analytics, Remote Config, FCM. Use when setting up crash reporting, analytics events, remote configuration, or push notifications.