diff --git a/.claude/skills/android-cli/SKILL.md b/.claude/skills/android-cli/SKILL.md new file mode 100644 index 0000000..9c7bfeb --- /dev/null +++ b/.claude/skills/android-cli/SKILL.md @@ -0,0 +1,98 @@ +--- +name: android-cli +description: "Reference for the AndroidSdk.Tool CLI (`android` command) - a .NET global tool for Android SDK automation. Use when: (1) Managing Android SDK packages (list, install, uninstall, download), (2) Working with AVDs/emulators (create, delete, start, list), (3) Interacting with connected devices via ADB (list devices, get properties, install/uninstall APKs), (4) Locating or configuring JDK for Android development, (5) Setting up CI/CD for Android or .NET MAUI development, (6) Reading APK manifest information, (7) Accepting SDK licenses non-interactively." +--- + +# AndroidSdk.Tool CLI Reference + +The `android` CLI is a .NET global tool providing programmatic access to Android SDK management. Install with: + +```bash +dotnet tool install -g AndroidSdk.Tool +``` + +## Command Groups + +| Group | Purpose | +|-------|---------| +| `sdk` | SDK package management (list, install, download, licenses) | +| `avd` | Android Virtual Device management (create, delete, start) | +| `device` | Connected device operations via ADB | +| `jdk` | JDK discovery and configuration | +| `apk` | APK inspection tools | + +## Quick Start Examples + +```bash +# Find SDK and show info +android sdk find +android sdk info + +# List available and installed packages +android sdk list --available +android sdk list --installed + +# Install emulator and system image +android sdk install --package emulator +android sdk install --package "system-images;android-34;google_apis;x86_64" + +# Create and start an emulator +android avd create --name TestDevice --sdk "system-images;android-34;google_apis;x86_64" --device pixel_6 +android avd start --name TestDevice --wait-boot + +# List connected devices and install APK +android device list +android device install --package ./app.apk +``` + +## Common Options + +Most commands support: +- `-f|--format ` - Output as JSON or XML instead of table +- `-h|--home ` - Specify Android SDK home path (overrides auto-detection) + +## Detailed Command Reference + +For complete parameter details, see: + +- **SDK Management**: [references/sdk-commands.md](references/sdk-commands.md) - Package listing, installation, downloads, licenses +- **AVD/Emulator**: [references/avd-emulator.md](references/avd-emulator.md) - Creating, configuring, and launching emulators +- **Device/ADB**: [references/device-adb.md](references/device-adb.md) - Device discovery, properties, app installation +- **JDK Management**: [references/jdk-commands.md](references/jdk-commands.md) - JDK location and .NET configuration +- **APK Inspection**: [references/apk-commands.md](references/apk-commands.md) - Reading APK manifest information + +## CI/CD Workflow Example + +```bash +# Download SDK to specific location (for CI) +android sdk download --home /opt/android-sdk --force + +# Accept all licenses non-interactively +android sdk accept-licenses --force + +# Install required components +android sdk install --package "platform-tools" +android sdk install --package "emulator" +android sdk install --package "platforms;android-34" +android sdk install --package "system-images;android-34;google_apis;x86_64" + +# Create headless emulator +android avd create --name CI_Emulator --sdk "system-images;android-34;google_apis;x86_64" --device pixel_6 --force + +# Start emulator in headless mode and wait for boot +android avd start --name CI_Emulator --no-window --no-audio --no-boot-anim --wait-boot --timeout 300 + +# Run tests, then devices are cleaned up when CI job ends +``` + +## Setting .NET MAUI/Xamarin Preferred Paths + +Configure the SDK/JDK paths that .NET Android workloads will use: + +```bash +# Set preferred Android SDK for .NET builds +android sdk dotnet-prefer --home /path/to/android-sdk + +# Set preferred JDK for .NET builds +android jdk dotnet-prefer --home /path/to/jdk +``` diff --git a/.claude/skills/android-cli/references/apk-commands.md b/.claude/skills/android-cli/references/apk-commands.md new file mode 100644 index 0000000..478bb51 --- /dev/null +++ b/.claude/skills/android-cli/references/apk-commands.md @@ -0,0 +1,120 @@ +# APK Commands Reference + +Commands for inspecting Android application packages (APK files). + +## Table of Contents + +- [apk manifest info](#apk-manifest-info) + +--- + +## apk manifest info + +Read and display APK manifest information. + +```bash +android apk manifest info --package [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-p\|--pkg\|--package ` | **Required.** Path to APK file | +| `-f\|--format ` | Output format | + +### Output Fields (Table Format) + +- **Package ID**: Application package identifier +- **Version Code**: Numeric version (used for updates) +- **Version Name**: Human-readable version string +- **Minimum SDK**: Minimum Android API level required +- **Target SDK**: Target Android API level +- **Maximum SDK**: Maximum Android API level (if set) + +### Output Formats + +- **Default (table)**: Key-value table with essential manifest info +- **XML (`--format xml`)**: Full AndroidManifest.xml content +- **JSON (`--format json`)**: Full manifest as JSON + +### Examples + +```bash +# Get basic manifest info +android apk manifest info --package ./app-release.apk + +# Get full manifest as XML +android apk manifest info --package ./app.apk --format xml + +# Get manifest as JSON for parsing +android apk manifest info --package ./app.apk --format json +``` + +### Use Cases + +#### Verify Build Configuration + +```bash +# Check that release APK targets correct SDK +android apk manifest info --package ./app-release.apk +``` + +#### Script Integration + +```bash +# Get package info as JSON for CI validation +info=$(android apk manifest info --package ./app.apk --format json) +package_id=$(echo "$info" | jq -r '.manifest.package') +version_code=$(echo "$info" | jq -r '.manifest."android:versionCode"') +``` + +#### Compare APK Versions + +```bash +# Compare version codes between builds +echo "Debug:" +android apk manifest info --package ./app-debug.apk + +echo "Release:" +android apk manifest info --package ./app-release.apk +``` + +--- + +## Common Manifest Properties + +### Package Identifier + +The unique application ID (e.g., `com.example.myapp`). This identifies the app on the device and in the Play Store. + +### Version Code + +Integer that Android uses to determine if an update is available. Must be incremented for each release. + +### Version Name + +Human-readable version string shown to users (e.g., `1.2.3`). + +### SDK Versions + +| Property | Description | +|----------|-------------| +| **minSdkVersion** | Minimum Android API level the app supports | +| **targetSdkVersion** | API level the app was designed and tested against | +| **maxSdkVersion** | Maximum API level (rarely used) | + +### Common API Levels + +| API Level | Android Version | +|-----------|-----------------| +| 34 | Android 14 | +| 33 | Android 13 | +| 32 | Android 12L | +| 31 | Android 12 | +| 30 | Android 11 | +| 29 | Android 10 | +| 28 | Android 9 (Pie) | +| 26 | Android 8.0 (Oreo) | +| 24 | Android 7.0 (Nougat) | +| 21 | Android 5.0 (Lollipop) | diff --git a/.claude/skills/android-cli/references/avd-emulator.md b/.claude/skills/android-cli/references/avd-emulator.md new file mode 100644 index 0000000..b34c260 --- /dev/null +++ b/.claude/skills/android-cli/references/avd-emulator.md @@ -0,0 +1,340 @@ +# AVD & Emulator Commands Reference + +Commands for managing Android Virtual Devices (AVDs) and running the emulator. + +## Table of Contents + +- [avd list](#avd-list) +- [avd targets](#avd-targets) +- [avd devices](#avd-devices) +- [avd create](#avd-create) +- [avd delete](#avd-delete) +- [avd start](#avd-start) + +--- + +## avd list + +List existing Android Virtual Devices. + +```bash +android avd list [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Output Fields + +- **Name**: AVD name (used with `avd start`) +- **Target**: Target Android version +- **Device**: Hardware device profile +- **Based On**: System image used +- **Path**: AVD directory location + +### Examples + +```bash +# List all AVDs +android avd list + +# Get JSON for scripting +android avd list --format json +``` + +--- + +## avd targets + +List available targets (Android API levels) for creating AVDs. + +```bash +android avd targets [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Output Fields + +- **Name**: Target name +- **Id**: Target identifier +- **Numeric Id**: Numeric identifier +- **API Level**: Android API level +- **Type**: Platform type +- **Revision**: Target revision + +### Examples + +```bash +# List available targets +android avd targets +``` + +--- + +## avd devices + +List available hardware device profiles for creating AVDs. + +```bash +android avd devices [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Output Fields + +- **Name**: Device profile name +- **Id**: Device identifier (use with `--device`) +- **NumericId**: Numeric identifier +- **Oem**: Device manufacturer (Google, etc.) + +### Examples + +```bash +# List device profiles +android avd devices + +# Common device IDs include: +# pixel, pixel_2, pixel_3, pixel_4, pixel_5, pixel_6, pixel_7 +# Nexus 5, Nexus 6, Nexus 7 +# And TV, Wear, Automotive profiles +``` + +--- + +## avd create + +Create a new Android Virtual Device. + +```bash +android avd create --name --sdk [options] +``` + +### Required Options + +| Option | Description | +|--------|-------------| +| `-n\|--name ` | **Required.** AVD name | +| `-s\|--sdk\|--sdkid ` | **Required.** System image package ID | + +### Optional Options + +| Option | Description | +|--------|-------------| +| `-d\|--device ` | Hardware device profile | +| `-t\|--target ` | Target ID | +| `-p\|--path ` | Custom AVD directory | +| `-a\|--abi ` | ABI (auto-selected if only one) | +| `--skin ` | Skin name | +| `--sdcard-path ` | SD card image path | +| `--sdcard-size ` | SD card size in MB | +| `-f\|--force` | Overwrite existing AVD | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Create basic emulator +android avd create \ + --name MyEmulator \ + --sdk "system-images;android-34;google_apis;x86_64" \ + --device pixel_6 + +# Create with specific options +android avd create \ + --name TestDevice \ + --sdk "system-images;android-34;google_apis_playstore;x86_64" \ + --device pixel_7 \ + --sdcard-size 512 \ + --force + +# Create for ARM architecture (Apple Silicon) +android avd create \ + --name ArmEmulator \ + --sdk "system-images;android-34;google_apis;arm64-v8a" \ + --device pixel_6 +``` + +### Common System Images + +First install the system image with `android sdk install`: + +| System Image | Description | +|--------------|-------------| +| `system-images;android-34;google_apis;x86_64` | Android 14, Google APIs, Intel/AMD | +| `system-images;android-34;google_apis;arm64-v8a` | Android 14, Google APIs, ARM | +| `system-images;android-34;google_apis_playstore;x86_64` | Android 14, with Play Store | +| `system-images;android-33;google_apis;x86_64` | Android 13 | +| `system-images;android-31;google_apis;x86_64` | Android 12 | + +--- + +## avd delete + +Delete an existing AVD. + +```bash +android avd delete --name [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-n\|--name ` | **Required.** AVD name to delete | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Delete AVD +android avd delete --name MyEmulator +``` + +--- + +## avd start + +Start an AVD emulator. + +```bash +android avd start --name [options] +``` + +### Required Options + +| Option | Description | +|--------|-------------| +| `-n\|--name ` | **Required.** AVD name to start | + +### Startup Options + +| Option | Description | +|--------|-------------| +| `-w\|--wait\|--wait-boot` | Wait for emulator to finish booting | +| `--wait-exit` | Wait for emulator process to exit | +| `-t\|--timeout ` | Boot timeout in seconds | +| `--wipe\|--wipe-data` | Wipe user data before starting | + +### Snapshot Options + +| Option | Description | +|--------|-------------| +| `--no-snapshot` | Disable snapshot load/save | +| `--no-snapshot-load` | Disable snapshot load only | +| `--no-snapshot-save` | Disable snapshot save only | + +### Display Options + +| Option | Description | +|--------|-------------| +| `--no-window` | Run headless (no graphical window) | +| `--no-boot-anim\|--no-boot-animation` | Disable boot animation (faster boot) | +| `--gpu ` | GPU emulation mode | + +### Hardware Options + +| Option | Description | +|--------|-------------| +| `--memory ` | RAM size (1536-8192 MB) | +| `--partition-size\|--data-partition-size ` | Data partition size | +| `--cache-size\|--cache-partition-size ` | Cache partition size (default: 66 MB) | +| `-p\|--port ` | Console/ADB port (5554-5682) | + +### Emulation Options + +| Option | Description | +|--------|-------------| +| `--engine ` | Emulator engine: `auto`, `classic`, `qemu2` | +| `--accel\|--acceleration ` | Acceleration: `auto`, `off`, `on` | +| `--screen ` | Touch screen: `touch`, `multi-touch`, `no-touch` | +| `--camera-back ` | Back camera: `emulated`, `webcam0`, `none` | +| `--camera-front ` | Front camera: `emulated`, `webcam0`, `none` | +| `--no-audio` | Disable audio | +| `--no-jni` | Disable extended JNI checks | + +### Advanced Options + +| Option | Description | +|--------|-------------| +| `--grpc ` | gRPC port number | +| `--grpc-use-jwt` | Use JWT with gRPC | +| `-v\|--verbose` | Print initialization messages | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Start emulator and wait for boot +android avd start --name MyEmulator --wait-boot + +# Start headless for CI +android avd start \ + --name CI_Emulator \ + --no-window \ + --no-audio \ + --no-boot-anim \ + --wait-boot \ + --timeout 300 + +# Start with clean state +android avd start --name MyEmulator --wipe-data --no-snapshot --wait-boot + +# Start with extra memory +android avd start --name MyEmulator --memory 4096 --wait-boot + +# Start on specific port +android avd start --name MyEmulator --port 5556 + +# Start and keep running until manually closed +android avd start --name MyEmulator --wait-exit +``` + +### CI/CD Headless Setup + +For running emulators in CI environments without a display: + +```bash +# Create emulator +android avd create \ + --name CI_Device \ + --sdk "system-images;android-34;google_apis;x86_64" \ + --device pixel_6 \ + --force + +# Start headless with all optimizations +android avd start \ + --name CI_Device \ + --no-window \ + --no-audio \ + --no-boot-anim \ + --no-snapshot \ + --acceleration auto \ + --wait-boot \ + --timeout 300 +``` + +### Troubleshooting + +**Slow startup**: Use `--no-boot-anim` and `--no-snapshot-load` for faster cold boots. + +**Out of memory**: Reduce `--memory` or close other applications. + +**Port conflicts**: Specify a different port with `--port`. + +**Headless crashes**: Ensure `--no-window` is used with `--gpu swiftshader_indirect` or `--gpu off` if GPU acceleration isn't available. diff --git a/.claude/skills/android-cli/references/device-adb.md b/.claude/skills/android-cli/references/device-adb.md new file mode 100644 index 0000000..2679fc5 --- /dev/null +++ b/.claude/skills/android-cli/references/device-adb.md @@ -0,0 +1,238 @@ +# Device & ADB Commands Reference + +Commands for interacting with connected Android devices and emulators via ADB. + +## Table of Contents + +- [device list](#device-list) +- [device info](#device-info) +- [device install](#device-install) +- [device uninstall](#device-uninstall) + +--- + +## device list + +List connected Android devices and running emulators. + +```bash +android device list [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Output Fields + +- **Serial**: Device serial number or emulator identifier +- **Emulator**: Whether it's an emulator (True/False) +- **Device**: Device codename +- **Model**: Device model name +- **Product**: Product name + +### Examples + +```bash +# List all devices +android device list + +# Get JSON for scripting +android device list --format json +``` + +### Serial Number Patterns + +- Physical devices: Alphanumeric string (e.g., `RF8M33XXXXX`) +- USB-connected: May show as IP:port if wireless debugging enabled +- Emulators: `emulator-5554`, `emulator-5556`, etc. +- Network ADB: `192.168.1.100:5555` + +--- + +## device info + +Get device properties (similar to `adb shell getprop`). + +```bash +android device info [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-d\|--id\|--device\|--serial ` | Filter by serial (supports regex) | +| `-p\|--prop\|--property ` | Property name filter (supports regex) | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Get all properties from all devices +android device info + +# Get specific property +android device info --property ro.product.model + +# Get properties matching pattern +android device info --property "ro\.product\..*" + +# Filter by device serial +android device info --device emulator-5554 + +# Filter device by regex +android device info --device "emulator.*" + +# Combined filters +android device info --device "emulator.*" --property ro.build.version.sdk +``` + +### Common Properties + +| Property | Description | +|----------|-------------| +| `ro.product.model` | Device model | +| `ro.product.brand` | Device brand | +| `ro.product.manufacturer` | Manufacturer | +| `ro.build.version.sdk` | API level | +| `ro.build.version.release` | Android version | +| `ro.product.cpu.abi` | CPU architecture | +| `ro.build.type` | Build type (user, userdebug, eng) | +| `ro.hardware` | Hardware name | +| `ro.serialno` | Serial number | + +### Device Selection Patterns + +The `--device` option supports both exact matches and regex: + +```bash +# Exact match +--device emulator-5554 + +# Regex patterns +--device "emulator.*" # Any emulator +--device "192\.168\..*" # Network devices +--device "RF8.*" # Samsung devices starting with RF8 +``` + +--- + +## device install + +Install an APK to a connected device. + +```bash +android device install --package [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-p\|--pkg\|--package ` | **Required.** Path to APK file | +| `-d\|--id\|--device\|--serial ` | Target device (required if multiple) | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Install to only connected device +android device install --package ./app-debug.apk + +# Install to specific device +android device install --device emulator-5554 --package ./app.apk + +# Install to emulator using pattern +android device install --device "emulator.*" --package ./app.apk +``` + +### Notes + +- If multiple devices are connected, you must specify `--device` +- The APK file must exist at the specified path +- Re-installing updates the existing app (preserves data) + +--- + +## device uninstall + +Uninstall an app from a connected device. + +```bash +android device uninstall --package [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-p\|--pkg\|--package ` | **Required.** Package name (e.g., `com.example.app`) | +| `-k\|--keep-data` | Keep app data and cache directories | +| `-d\|--id\|--device\|--serial ` | Target device (required if multiple) | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Uninstall app +android device uninstall --package com.example.myapp + +# Uninstall but keep data +android device uninstall --package com.example.myapp --keep-data + +# Uninstall from specific device +android device uninstall --device emulator-5554 --package com.example.myapp +``` + +### Notes + +- Use the package name (e.g., `com.example.app`), not the APK filename +- `--keep-data` preserves app data for potential reinstallation +- System apps cannot be uninstalled without root + +--- + +## Common Workflows + +### Install and Test App + +```bash +# List devices +android device list + +# Install APK +android device install --package ./app-debug.apk --device emulator-5554 + +# Verify installation by checking properties +android device info --device emulator-5554 --property ro.build.version.sdk +``` + +### Multi-Device Deployment + +```bash +# Get device list as JSON for scripting +devices=$(android device list --format json) + +# Install to first emulator found +android device install --device "emulator.*" --package ./app.apk +``` + +### Device Discovery for CI + +```bash +# Check if any device is connected +if android device list --format json | grep -q "Serial"; then + echo "Device connected" + android device install --package ./app.apk +else + echo "No device found" + exit 1 +fi +``` diff --git a/.claude/skills/android-cli/references/jdk-commands.md b/.claude/skills/android-cli/references/jdk-commands.md new file mode 100644 index 0000000..c3abc0e --- /dev/null +++ b/.claude/skills/android-cli/references/jdk-commands.md @@ -0,0 +1,223 @@ +# JDK Commands Reference + +Commands for discovering Java Development Kits and configuring .NET Android builds. + +## Table of Contents + +- [jdk list](#jdk-list) +- [jdk find](#jdk-find) +- [jdk dotnet-prefer](#jdk-dotnet-prefer) + +--- + +## jdk list + +List discovered JDK installations on the system. + +```bash +android jdk list [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-v\|--version ` | Filter by version (NuGet version range syntax) | +| `-h\|--home ` | Specific JDK home to include | +| `-p\|--path ` | Additional paths to search (repeatable) | +| `-f\|--format ` | Output format | + +### Output Fields + +- **Version**: JDK version +- **Path**: JDK home directory +- **Java**: Path to `java` executable +- **JavaC**: Path to `javac` executable +- **DotNet Preferred**: Whether .NET is configured to use this JDK +- **From Env Var**: Whether discovered via `JAVA_HOME` environment variable + +### Examples + +```bash +# List all JDKs +android jdk list + +# List JDKs version 17 or higher +android jdk list --version ">=17.0.0" + +# List JDKs in specific version range +android jdk list --version "[17.0.0, 22.0.0)" + +# Include custom path +android jdk list --path /opt/custom-jdk + +# Get JSON output +android jdk list --format json +``` + +### Version Range Syntax + +Uses NuGet version range syntax: + +| Syntax | Description | +|--------|-------------| +| `17.0.0` | Minimum version 17.0.0 | +| `[17.0.0]` | Exact version 17.0.0 | +| `[17.0.0, 21.0.0]` | Range inclusive | +| `[17.0.0, 21.0.0)` | Range, exclusive upper bound | +| `>=17.0.0` | Version 17.0.0 or higher | + +### Search Locations + +The tool searches: +- `JAVA_HOME` environment variable +- Platform-specific standard locations: + - **macOS**: `/Library/Java/JavaVirtualMachines/*/Contents/Home` + - **Linux**: `/usr/lib/jvm/*` + - **Windows**: `C:\Program Files\Java\*`, `C:\Program Files\Microsoft\jdk-*` +- .NET Android workload configuration + +--- + +## jdk find + +Find and output the best matching JDK home path. + +```bash +android jdk find [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-v\|--version ` | Version filter (default: `>=17.0.0`) | + +Returns the `JAVA_HOME` path for the newest JDK matching the version criteria. + +### Examples + +```bash +# Find newest JDK (17+) +android jdk find + +# Find JDK 17 specifically +android jdk find --version "17.*" + +# Find JDK 21 or higher +android jdk find --version ">=21.0.0" + +# Use in script +export JAVA_HOME=$(android jdk find) +``` + +### Notes + +- By default, requires JDK 17+ (required for modern Android tooling) +- Returns the newest version when multiple JDKs match +- Returns nothing if no matching JDK is found + +--- + +## jdk dotnet-prefer + +Set the preferred JDK for .NET Android/MAUI builds. + +```bash +android jdk dotnet-prefer --home +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-h\|--home ` | **Required.** JDK home path to prefer | + +This updates the .NET workload configuration so that Android builds use the specified JDK. + +### Examples + +```bash +# Set preferred JDK +android jdk dotnet-prefer --home /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home + +# Use with auto-discovered JDK +android jdk dotnet-prefer --home $(android jdk find) + +# Set specific version +android jdk dotnet-prefer --home $(android jdk find --version "17.*") +``` + +### Where Configuration is Stored + +The .NET Android workload stores preferences in: +- **macOS/Linux**: `~/.config/Microsoft/Android/sdk.config` +- **Windows**: `%LOCALAPPDATA%\Microsoft\Android\sdk.config` + +--- + +## JDK Requirements + +### Android SDK Tools + +- **sdkmanager**: Requires JDK to run (uses Java) +- **avdmanager**: Requires JDK to run (uses Java) +- **adb/emulator**: Do not require JDK (native binaries) + +### .NET Android Builds + +- **.NET 8+**: Requires JDK 17+ +- **.NET 7**: Requires JDK 11+ +- Build process uses JDK for: + - D8/R8 dexing + - AAPT2 resource processing + - APK signing + +### Recommended JDKs + +| JDK | Notes | +|-----|-------| +| Microsoft Build of OpenJDK | Recommended for .NET development | +| Eclipse Temurin (Adoptium) | Popular open-source option | +| Amazon Corretto | AWS-supported OpenJDK | +| Oracle JDK | Requires license for commercial use | + +--- + +## Common Workflows + +### Setup for .NET MAUI Development + +```bash +# Find and set preferred JDK +android jdk dotnet-prefer --home $(android jdk find) + +# Verify +android jdk list +``` + +### CI/CD JDK Configuration + +```bash +# Verify JDK is available +if jdk_path=$(android jdk find --version ">=17.0.0"); then + echo "Found JDK at: $jdk_path" + export JAVA_HOME="$jdk_path" +else + echo "No suitable JDK found" + exit 1 +fi +``` + +### Multiple JDK Management + +```bash +# List all JDKs +android jdk list + +# Use JDK 17 for Android builds +android jdk dotnet-prefer --home $(android jdk find --version "[17.0.0, 18.0.0)") + +# Verify configuration +android sdk info +``` diff --git a/.claude/skills/android-cli/references/sdk-commands.md b/.claude/skills/android-cli/references/sdk-commands.md new file mode 100644 index 0000000..a5cf72c --- /dev/null +++ b/.claude/skills/android-cli/references/sdk-commands.md @@ -0,0 +1,311 @@ +# SDK Commands Reference + +Commands for managing Android SDK packages, licenses, and configuration. + +## Table of Contents + +- [sdk list](#sdk-list) +- [sdk install](#sdk-install) +- [sdk uninstall](#sdk-uninstall) +- [sdk download](#sdk-download) +- [sdk info](#sdk-info) +- [sdk find](#sdk-find) +- [sdk licenses](#sdk-licenses) +- [sdk accept-licenses](#sdk-accept-licenses) +- [sdk dotnet-prefer](#sdk-dotnet-prefer) + +--- + +## sdk list + +List Android SDK packages (available and/or installed). + +```bash +android sdk list [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `--available` | Show only packages available for installation | +| `--installed` | Show only installed packages | +| `--all` | Show all packages | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# List all packages (available + installed) +android sdk list + +# List only available packages +android sdk list --available + +# List installed packages as JSON +android sdk list --installed --format json +``` + +### Output Fields + +- **Package**: Package path/identifier (e.g., `platforms;android-34`) +- **Version**: Package version +- **Description**: Human-readable description +- **Location**: Installation path (installed packages only) + +--- + +## sdk install + +Install or update Android SDK packages. + +```bash +android sdk install --package [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-p\|--package ` | Package(s) to install (repeatable) | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Install single package +android sdk install --package emulator + +# Install multiple packages +android sdk install --package "platforms;android-34" --package "platform-tools" + +# Install system image +android sdk install --package "system-images;android-34;google_apis;x86_64" + +# Install build tools +android sdk install --package "build-tools;34.0.0" +``` + +### Common Packages + +| Package | Description | +|---------|-------------| +| `platform-tools` | ADB and fastboot | +| `emulator` | Android Emulator | +| `platforms;android-XX` | Android platform (replace XX with API level) | +| `build-tools;XX.X.X` | Build tools version | +| `system-images;android-XX;google_apis;ARCH` | System image for emulator | +| `cmdline-tools;latest` | Command-line tools | +| `ndk;XX.X.XXXXX` | Native Development Kit | + +--- + +## sdk uninstall + +Uninstall Android SDK packages. + +```bash +android sdk uninstall --package [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-p\|--package ` | Package(s) to uninstall (repeatable) | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Uninstall emulator +android sdk uninstall --package emulator + +# Uninstall old platform +android sdk uninstall --package "platforms;android-30" +``` + +--- + +## sdk download + +Download a fresh copy of the Android SDK command-line tools. Useful for bootstrapping a new SDK installation. + +```bash +android sdk download --home [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-h\|--home ` | **Required.** Target directory for SDK | +| `-f\|--force` | Delete existing directory contents first | +| `--preview` | Allow preview/beta versions | +| `--version ` | Specific version to download | +| `--arch ` | Architecture: `x64`, `aarch64` | +| `--os ` | OS: `windows`, `linux`, `macos` | + +### Examples + +```bash +# Download SDK to new directory +android sdk download --home ~/android-sdk + +# Force reinstall +android sdk download --home ~/android-sdk --force + +# Download specific architecture for CI cross-platform +android sdk download --home /opt/android-sdk --os linux --arch x64 +``` + +--- + +## sdk info + +Display Android SDK installation information. + +```bash +android sdk info [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Output Fields + +- **Path**: SDK installation path +- **Version**: SDK tools version +- **IsUpToDate**: Whether tools are up to date +- **Channel**: Update channel (stable, beta, etc.) +- **DotNetPreferred**: Whether this SDK is the .NET preferred location +- **WriteAccess**: Whether the SDK directory is writable + +Also lists discovered JDKs with their versions and paths. + +### Examples + +```bash +# Show SDK info +android sdk info + +# Get JSON output for scripting +android sdk info --format json +``` + +--- + +## sdk find + +Find and output the Android SDK home path. + +```bash +android sdk find +``` + +Searches standard locations and outputs the discovered `ANDROID_HOME` path. Useful for scripts that need to determine SDK location. + +### Examples + +```bash +# Get SDK path +android sdk find + +# Use in script +export ANDROID_HOME=$(android sdk find) +``` + +--- + +## sdk licenses + +List Android SDK licenses and their acceptance status. + +```bash +android sdk licenses [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-a\|--accepted` | Show only accepted licenses | +| `-u\|--unaccepted` | Show only unaccepted licenses | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# List all licenses +android sdk licenses + +# Check for unaccepted licenses +android sdk licenses --unaccepted + +# Get license status as JSON +android sdk licenses --format json +``` + +--- + +## sdk accept-licenses + +Accept Android SDK licenses (required before installing some packages). + +```bash +android sdk accept-licenses [options] +``` + +### Options + +| Option | Description | +|--------|-------------| +| `--force` | Accept all licenses without prompting | +| `-f\|--format ` | Output format | +| `-h\|--home ` | Android SDK home path | + +### Examples + +```bash +# Interactive acceptance +android sdk accept-licenses + +# Non-interactive (for CI/automation) +android sdk accept-licenses --force +``` + +--- + +## sdk dotnet-prefer + +Set the preferred Android SDK location for .NET Android/MAUI builds. + +```bash +android sdk dotnet-prefer --home +``` + +### Options + +| Option | Description | +|--------|-------------| +| `-h\|--home ` | **Required.** Android SDK path to prefer | + +This updates the .NET workload configuration so that `dotnet build` for Android projects uses this SDK. + +### Examples + +```bash +# Set preferred SDK +android sdk dotnet-prefer --home /opt/android-sdk + +# Use with auto-discovered path +android sdk dotnet-prefer --home $(android sdk find) +```