Android Development Skill for Gemini CLI
This skill enables Gemini CLI to serve as a full Android development copilot — building, debugging, deploying, testing, and managing Android projects alongside Android Studio and ADB.
Quick Reference
Before diving into a task, determine which reference file to read:
| Task | Reference |
|---|---|
| ADB device management, debugging, shell | references/adb-commands.md |
| Gradle builds, signing, dependencies | references/gradle-commands.md |
| Emulator & SDK management | references/emulator-sdk.md |
| Android Studio CLI integration | references/studio-cli.md |
| Testing (unit, instrumented, UI) | references/testing.md |
Read the relevant reference file BEFORE executing commands. Each contains battle-tested patterns and edge-case handling.
Environment Setup
Before any Android work, verify the environment:
# Run the environment check script
./scripts/check_env.sh
This validates:
ANDROID_HOME/ANDROID_SDK_ROOTis setadb,gradle/gradlew,sdkmanager,avdmanager,emulatorare in PATH- At least one device or emulator is connected
- Java/JDK version is compatible
If the environment check fails, guide the user through setup based on their OS.
Core Workflows
1. Build & Deploy
The most common workflow — build an APK/AAB and install it on a device:
# Clean build
./gradlew clean assembleDebug
# Install on connected device
./gradlew installDebug
# Or manually with ADB
adb install -r app/build/outputs/apk/debug/app-debug.apk
For release builds, read references/gradle-commands.md for signing configuration.
2. Debug & Inspect
Stream logs filtered by app package:
# Get the app's PID
adb shell pidof -s com.example.app
# Stream filtered logs
adb logcat --pid=<PID>
# Or filter by tag
adb logcat -s MyAppTag:D *:S
For advanced debugging (layout inspector, memory profiling, network inspection),
read references/adb-commands.md.
3. Test
# Unit tests
./gradlew test
# Instrumented tests (requires device/emulator)
./gradlew connectedAndroidTest
# Specific test class
./gradlew test --tests "com.example.MyTest"
Read references/testing.md for Espresso, UI Automator, and screenshot testing patterns.
4. Emulator Management
# List available AVDs
emulator -list-avds
# Launch emulator
emulator -avd Pixel_7_API_34 -no-snapshot-load
# Create new AVD
avdmanager create avd -n "Pixel_7_API_34" \
-k "system-images;android-34;google_apis;x86_64" \
-d "pixel_7"
Read references/emulator-sdk.md for headless CI, snapshot management, and system image installation.
Project Scaffolding
When the user asks to create a new Android project from the CLI (without Android Studio UI):
# Use the scaffolding script
./scripts/scaffold_project.sh <project-name> <package-name> [--compose] [--min-sdk 24]
This creates a standard project structure with:
- Kotlin as the default language
- Material 3 / Jetpack Compose (if
--composeflag) - Version catalog (
libs.versions.toml) - Standard Gradle wrapper
Common Patterns
Multi-device deployment
# Deploy to all connected devices
adb devices | grep -v "List" | awk '{print $1}' | xargs -I {} adb -s {} install -r app.apk
Wireless debugging (Android 11+)
adb pair <ip>:<pairing_port> # Enter pairing code
adb connect <ip>:<connect_port>
Deep links testing
adb shell am start -a android.intent.action.VIEW \
-d "myapp://screen/detail?id=123" \
com.example.app
Screenshot & screen recording
adb shell screencap -p /sdcard/screen.png && adb pull /sdcard/screen.png .
adb shell screenrecord /sdcard/demo.mp4 # Ctrl+C to stop, then adb pull
Error Recovery
When builds or deployments fail, follow this diagnostic flow:
- Build failure →
./gradlew assembleDebug --stacktrace --info - Install failure →
adb install -r -d app.apk(allow downgrade) oradb uninstall <pkg>first - Device not found →
adb kill-server && adb start-server && adb devices - Emulator crash →
emulator -avd <name> -wipe-data -no-snapshot-load - Gradle sync fail →
./gradlew --stop && rm -rf .gradle && ./gradlew clean - SDK missing →
sdkmanager --list | grep <needed>thensdkmanager "<package>"
Tool Categories
This skill provides commands in these categories:
ADB Tools
- Device management, app lifecycle, file transfer, shell commands
- Log streaming with filters
- Screenshot and screen recording
Gradle Tools
- Build tasks, dependency analysis, project info
- Testing, linting, signing
Emulator Tools
- AVD management, launch, snapshot control
- Headless mode for CI/CD
SDK Tools
- Package installation and updates
- License acceptance
APK Analysis
- APK inspection, permissions, manifest