home / skills / hitoshura25 / claude-devtools / android-espresso-dependencies
This skill adds Espresso and AndroidX Test dependencies to your Android project and guides optional test runner configuration.
npx playbooks add skill hitoshura25/claude-devtools --skill android-espresso-dependenciesReview the files below or copy the command above to add this skill to your agents.
---
name: android-espresso-dependencies
description: Add Espresso and AndroidX Test dependencies to Android project
category: android
version: 1.0.0
inputs:
- project_path: Path to Android project
outputs:
- Updated app/build.gradle.kts with test dependencies
verify: "./gradlew dependencies | grep espresso"
---
# Android Espresso Dependencies
Adds Espresso and AndroidX Test dependencies required for E2E UI testing.
## Prerequisites
- Android project with Gradle
- Kotlin DSL (build.gradle.kts)
- Minimum SDK 21+ (Espresso requirement)
## Inputs
| Input | Required | Default | Description |
|-------|----------|---------|-------------|
| project_path | Yes | . | Android project root |
## Process
### Step 1: Add Espresso Dependencies
Add to `app/build.gradle.kts`:
```kotlin
dependencies {
// Existing dependencies...
// Espresso core
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.5.1")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.5.1")
// AndroidX Test
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test:rules:1.5.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.5")
}
```
**Detection logic:**
- Check if dependencies already exist (don't duplicate)
- Use latest stable versions
- Keep existing test dependencies
### Step 2: Configure Test Runner (Optional)
If user wants test orchestrator for better isolation:
```kotlin
android {
// ... existing config ...
defaultConfig {
// ... existing config ...
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
testOptions {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
animationsDisabled = true
}
}
dependencies {
// ... existing dependencies ...
androidTestUtil("androidx.test:orchestrator:1.4.2")
}
```
**Ask user:** "Enable test orchestrator for better test isolation? (Recommended for large test suites)"
## Verification
**MANDATORY:** Run these commands:
```bash
# Sync Gradle
./gradlew dependencies --configuration androidTestRuntimeClasspath
# Verify Espresso dependencies
./gradlew dependencies | grep espresso && echo "✓ Espresso dependencies added"
# Verify AndroidX Test dependencies
./gradlew dependencies | grep "androidx.test" && echo "✓ AndroidX Test dependencies added"
```
**Expected output:**
- ✓ Espresso dependencies added
- ✓ AndroidX Test dependencies added
## Outputs
| Output | Location | Description |
|--------|----------|-------------|
| Dependencies | app/build.gradle.kts | Espresso and AndroidX Test libs |
## Troubleshooting
### "Dependency resolution failed"
**Cause:** Version conflict with existing dependencies
**Fix:** Check for conflicting androidx.test versions, align all to same version
### "Minimum SDK too low"
**Cause:** minSdk < 21
**Fix:** Espresso requires API 21+, update minSdk in defaultConfig
## Completion Criteria
- [ ] Espresso dependencies in app/build.gradle.kts
- [ ] AndroidX Test dependencies in app/build.gradle.kts
- [ ] Test runner configured
- [ ] `./gradlew dependencies` shows espresso libraries
This skill adds Espresso and AndroidX Test dependencies and optional test orchestrator configuration to an Android Gradle project using Kotlin DSL. It ensures required test libraries are present, avoids duplicate entries, and verifies installation via Gradle dependency checks. The skill targets projects with minSdk 21+ and Kotlin-based build.gradle.kts files.
The skill inspects app/build.gradle.kts for existing androidTest dependencies and injects Espresso and AndroidX Test artifacts only if they aren’t already present. It can also modify defaultConfig and testOptions to set the AndroidJUnitRunner and enable the AndroidX Test Orchestrator, and it adds androidTestUtil for the orchestrator when requested. After changes it runs Gradle dependency queries to confirm the libraries are visible on the androidTest runtime classpath.
My project uses Groovy build scripts (build.gradle). Can I use this skill?
This skill is designed for Kotlin DSL (build.gradle.kts). For Groovy builds you can apply the same dependency coordinates manually or convert the script to Kotlin DSL first.
Gradle dependency resolution failed after adding, what should I check?
Check for conflicting androidx.test or espresso versions across modules and align them. Also confirm minSdk >= 21 and that the dependency was added to the app module, then rerun ./gradlew dependencies --configuration androidTestRuntimeClasspath.