This guide covers how to set up and run Appium tests for Android on Windows. It provides Windows-specific instructions for building, deploying, and testing the Android application.
- Prerequisites
- Quick Start
- Environment Setup
- Running Tests
- Scripts Reference
- Troubleshooting
- CI/CD Considerations
- Windows 10/11 (64-bit)
- Android Studio or Android SDK Command-line Tools
- Java Development Kit (JDK) 17 (NOT Java 24+ which is incompatible)
- Node.js (version 20.x or later)
- Android device or emulator
- USB drivers (for physical device testing)
REM 1. Create .env file in app\ directory with Auth0 configuration
REM See app\.env.example for required variables
REM 2. Setup environment and verify
scripts\windows\setup-test-env.bat
REM 3. Build and test (first run)
scripts\windows\run-local-test-android.bat --build welcome
REM 4. Fast iteration (subsequent runs)
scripts\windows\run-local-test-android.bat --skip-build welcome
REM 5. Run all tests
scripts\windows\run-local-test-android.bat all| Scenario | Command |
|---|---|
| Setup environment | scripts\windows\setup-test-env.bat |
| List emulators | scripts\windows\setup-test-env.bat --list-emulators |
| Start emulator | scripts\windows\setup-test-env.bat --start-emulator Pixel_8_API_34 |
| Stop Appium | scripts\windows\setup-test-env.bat --stop-appium |
| Reuse last build | scripts\windows\run-local-test-android.bat --skip-build welcome |
| Test specific file | scripts\windows\run-local-test-android.bat .\test\specs\welcome.e2e.js |
| Run all tests | scripts\windows\run-local-test-android.bat all |
| List suite tests | scripts\windows\run-local-test-android.bat --dry-run welcome |
Java 17 is required for Android development. Java 24+ is NOT compatible.
- Download from Eclipse Adoptium
- Select Temurin 17 (LTS) for Windows x64
- Run the MSI installer
- During installation, check "Set JAVA_HOME variable"
- Download and install JDK 17
- Set environment variables:
REM Set JAVA_HOME (adjust path to your installation)
setx JAVA_HOME "C:\Program Files\Eclipse Adoptium\jdk-17.0.10+7-hotspot"
REM Add to PATH
setx PATH "%PATH%;%JAVA_HOME%\bin"java -version
REM Should show: openjdk version "17.x.x"
echo %JAVA_HOME%
REM Should show your JDK installation path- Download Android Studio
- Run installer with default settings
- Complete the setup wizard (downloads SDK components)
- SDK will be installed at:
%LOCALAPPDATA%\Android\Sdk
- Download Command-line tools
- Extract to
C:\Android\cmdline-tools\latest - Install required components:
cd C:\Android\cmdline-tools\latest\bin
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
sdkmanager "system-images;android-34;google_apis;x86_64"
sdkmanager --licensesREM Set ANDROID_HOME
setx ANDROID_HOME "%LOCALAPPDATA%\Android\Sdk"
REM Add tools to PATH
setx PATH "%PATH%;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\emulator;%ANDROID_HOME%\cmdline-tools\latest\bin"adb --version
REM Should show Android Debug Bridge version
emulator -list-avds
REM Should list available emulators (may be empty initially)If you don't have a physical device, create an emulator:
- Open Android Studio
- Go to Tools > Device Manager
- Click Create Device
- Select Pixel 8 (or similar)
- Select API 34 system image
- Complete wizard and click Finish
REM Create emulator
avdmanager create avd -n Pixel_8_API_34 -k "system-images;android-34;google_apis;x86_64" -d "pixel_8"
REM List emulators to verify
emulator -list-avds- Download from nodejs.org
- Install the LTS version (20.x)
- Verify installation:
node --version
npm --versionREM Install Appium globally
npm install -g appium@3.1.1
REM Install UiAutomator2 driver for Android
appium driver install uiautomator2
REM Verify installation
appium --version
appium driver list --installedTo test on a physical Android device:
-
Enable Developer Options:
- Go to Settings > About Phone
- Tap "Build Number" 7 times
-
Enable USB Debugging:
- Go to Settings > Developer Options
- Enable "USB Debugging"
-
Connect Device:
- Connect via USB cable
- Accept the "Allow USB debugging?" prompt
- Check "Always allow from this computer"
-
Install USB Drivers (if needed):
- For Google devices: Google USB Driver
- For other manufacturers: Check manufacturer's website
-
Verify Connection:
adb devices REM Should show your device with "device" status
Run the setup script to load environment and check connectivity:
scripts\windows\setup-test-env.batThis will:
- ✅ Load environment variables from .env file
- ✅ Configure platform-specific settings (Android/iOS)
- ✅ Detect connected devices
- ✅ Display configuration summary
To list available emulators:
scripts\windows\setup-test-env.bat --list-emulatorsThe primary way to run tests on Windows:
REM Run specific test suite
scripts\windows\run-local-test-android.bat welcome
REM Run all tests
scripts\windows\run-local-test-android.bat all
REM Run specific spec file
scripts\windows\run-local-test-android.bat .\test\specs\welcome.e2e.js
REM Build and run (when you've made app changes)
scripts\windows\run-local-test-android.bat --build welcome
REM Skip build, reuse last APK (fast iteration)
scripts\windows\run-local-test-android.bat --skip-build welcome
REM Use specific emulator
scripts\windows\run-local-test-android.bat --emulator Pixel_8_API_34 welcomeAlternative with better error handling:
# Run specific suite (uses .env file for Auth0 config)
.\scripts\windows\run-local-test-android.ps1 welcome
# Skip build, reuse last APK
.\scripts\windows\run-local-test-android.ps1 -SkipBuild welcome
# Use specific emulator
.\scripts\windows\run-local-test-android.ps1 -EmulatorName "Pixel_8_API_34" welcome
# Build and run (requires .env file with Auth0 configuration)
.\scripts\windows\run-local-test-android.ps1 -Build welcomeNote: The PowerShell script supports legacy
-Environmentand-ClientIdparameters for backwards compatibility, but the recommended approach is to configure Auth0 settings in the.envfile in theapp\directory.
For more control over the process:
REM 1. Setup environment
scripts\windows\setup-test-env.bat
REM 2. Start Appium server (in separate terminal)
appium --address 127.0.0.1 --port 4723
REM 3. Run tests (this will build if needed)
scripts\windows\run-local-test-android.bat --build welcomeMain testing script that handles the complete workflow.
Prerequisites: .env file must exist in app\ directory with Auth0 configuration
| Option | Description |
|---|---|
--build, -b |
Build the app before testing |
--skip-build, -s |
Install existing APK from last build |
--emulator |
Specify emulator AVD name to start |
--list, --dry-run |
List all test cases without running them |
--verbose, -v |
Enable verbose output |
--help, -h |
Show help message |
Sets up the test environment by loading .env variables and configuring platform settings.
| Option | Description |
|---|---|
--platform, -p |
Target platform: android or ios (default: android) |
--list-emulators, -l |
List available Android emulators |
--start-emulator, -e |
Start Android emulator by AVD name |
--start-appium, -a |
Start Appium server with inspector plugin |
--stop-appium |
Stop all running Appium processes |
--help, -h |
Show help message |
PowerShell alternative to the batch script with enhanced error handling.
| Parameter | Description |
|---|---|
-Build |
Build the app before testing (requires .env file) |
-SkipBuild |
Skip build and install existing APK from last build |
-EmulatorName |
Specify emulator AVD name to start |
-List, -DryRun |
List all test cases without running them |
TestTarget |
Suite name, spec file, or 'all' (required) |
REM Find your Java installation
where java
REM Set JAVA_HOME (adjust path as needed)
setx JAVA_HOME "C:\Program Files\Eclipse Adoptium\jdk-17.0.10+7-hotspot"
REM Restart your terminalThis means you're using Java 24+. Install Java 17:
REM 1. Install Java 17 from Adoptium
REM 2. Set JAVA_HOME to Java 17 path
setx JAVA_HOME "C:\Program Files\Eclipse Adoptium\jdk-17.0.10+7-hotspot"
REM 3. Stop Gradle daemons
cd app\android
gradlew --stop
REM 4. Clean and rebuild
gradlew cleanREM Set ANDROID_HOME (adjust if you installed SDK elsewhere)
setx ANDROID_HOME "%LOCALAPPDATA%\Android\Sdk"
REM Add to PATH
setx PATH "%PATH%;%ANDROID_HOME%\platform-tools"
REM Restart your terminalREM Check if adb exists
dir %ANDROID_HOME%\platform-tools\adb.exe
REM Add platform-tools to PATH
setx PATH "%PATH%;%ANDROID_HOME%\platform-tools"
REM Or use full path
%ANDROID_HOME%\platform-tools\adb devices-
Check USB cable and try different port
-
Ensure USB Debugging is enabled
-
Revoke and re-authorize USB debugging:
- Settings > Developer Options > Revoke USB debugging authorizations
- Disconnect and reconnect device
- Accept authorization prompt
-
Install manufacturer USB drivers
-
Try:
adb kill-server adb start-server adb devices
REM Uninstall existing app first
adb uninstall com.softwareone.marketplaceMobile
REM Then install new APK
adb install path\to\app.apk-
Enable virtualization in BIOS (Intel VT-x or AMD-V)
-
Install HAXM (Intel) or enable Windows Hypervisor Platform:
- Control Panel > Programs > Turn Windows features on or off
- Check "Windows Hypervisor Platform"
- Restart computer
-
Try with software rendering:
emulator -avd YOUR_AVD -gpu swiftshader_indirect
- Use x86_64 system image instead of ARM
- Allocate more RAM to emulator
- Enable GPU acceleration in AVD settings
- Close other heavy applications
REM Install Appium globally
npm install -g appium@3.1.1
REM Verify it's in PATH
where appiumREM Install the driver
appium driver install uiautomator2
REM Verify installation
appium driver list --installed- Check device is connected:
adb devices - Verify app is installed:
adb shell pm list packages | findstr softwareone - Check Appium logs for specific error
- Try clearing app data:
adb shell pm clear com.softwareone.marketplaceMobile
If you get an execution policy error:
# Check current policy
Get-ExecutionPolicy
# Allow local scripts (for current user only)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Or run script with bypass
powershell -ExecutionPolicy Bypass -File .\scripts\windows\run-local-test-android.ps1 welcomecd app\android
REM Stop Gradle daemons
gradlew --stop
REM Clean project
gradlew clean
REM Try build again with more memory
set GRADLE_OPTS=-Xmx4096m
gradlew assembleDebugCreate app\android\local.properties:
sdk.dir=C:\\Users\\YourUser\\AppData\\Local\\Android\\SdkWhile Windows runners can be used for Android testing, there are trade-offs:
Pros:
- Native Windows environment
- Good for Windows-specific testing
- Access to Windows tools
Cons:
- Slower emulator startup (no hardware acceleration in most runners)
- Higher cost than Linux runners
- Longer build times
Recommendation: Use macOS runners for Android CI/CD testing when possible, as they provide better emulator performance with hardware acceleration.
If you need Windows-based CI/CD:
name: Android E2E Tests (Windows)
on:
workflow_dispatch:
jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install dependencies
run: |
cd app
npm ci
- name: Install Appium
run: |
npm install -g appium@3.1.1
appium driver install uiautomator2
# Note: Emulator setup on Windows CI is complex
# Consider using macOS runners instead| Variable | Description | Default/Example |
|---|---|---|
JAVA_HOME |
JDK installation path | C:\Program Files\Eclipse Adoptium\jdk-17.0.10+7-hotspot |
ANDROID_HOME |
Android SDK path | %LOCALAPPDATA%\Android\Sdk |
PLATFORM_NAME |
Target platform | Android |
DEVICE_UDID |
Device identifier | Auto-detected |
APP_PACKAGE |
Android app package | com.softwareone.marketplaceMobile |
APP_ACTIVITY |
Main activity | .MainActivity |
APPIUM_HOST |
Appium server host | 127.0.0.1 |
APPIUM_PORT |
Appium server port | 4723 |
REM === Device Management ===
adb devices REM List connected devices
adb shell getprop ro.product.model REM Get device model
adb shell getprop ro.build.version.sdk REM Get Android API level
REM === App Management ===
adb install path\to\app.apk REM Install APK
adb install -r path\to\app.apk REM Replace existing app
adb uninstall com.package.name REM Uninstall app
adb shell pm list packages REM List installed packages
adb shell pm clear com.package.name REM Clear app data
REM === Emulator ===
emulator -list-avds REM List available emulators
emulator -avd AVD_NAME REM Start emulator
emulator -avd AVD_NAME -no-audio REM Start without audio
REM === Debugging ===
adb logcat REM View device logs
adb logcat | findstr "ReactNative" REM Filter React Native logs
adb shell screencap /sdcard/screen.png REM Take screenshot
adb pull /sdcard/screen.png REM Pull file from device
REM === Appium ===
appium --version REM Check Appium version
appium driver list --installed REM List installed drivers
appium --address 127.0.0.1 --port 4723 REM Start Appium server- LOCAL_BUILD_ANDROID.md - Android build guide
- APPIUM_IOS_TESTING.md - iOS testing guide (macOS)
- EXTENDING_TEST_FRAMEWORK.md - Adding new tests
Note: This guide focuses on Windows-specific setup and commands. For cross-platform test architecture and writing tests, see the main testing documentation.