This guide covers how to run Appium tests for Android on macOS and Linux. It provides cross-platform instructions for building, deploying, and testing the Android application.
The run-local-test.sh script contains logic to try and start an Appium server that matches the version declared in app/package.json. It prefers a local project binary, then npx appium@<version>, then a global appium binary. If you experience mismatched Appium versions when the script starts the server, see Appium Version & Binary Sync for diagnostics and remediation steps.
- macOS or Linux (recommended for Android testing)
- 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
- Appium with UiAutomator2 driver
# 1. Install UiAutomator2 driver (one-time setup)
appium driver install uiautomator2
# 2. Create .env file in app/ directory with Auth0 configuration
# See app/.env for required variables
# 3. Start an Android emulator or connect a device
emulator -avd YOUR_EMULATOR_NAME
# 4. Build and test (first run)
./scripts/deploy-android.sh
./scripts/run-local-test.sh --platform android welcome
# 5. Fast iteration (subsequent runs)
./scripts/run-local-test.sh --platform android welcome
# 6. Run all tests
./scripts/run-local-test.sh --platform android all| Scenario | Command |
|---|---|
| Check environment | Check Android SDK and adb are available |
| Build + test | ./scripts/run-local-test.sh --platform android --build welcome |
| Reuse installed app | ./scripts/run-local-test.sh --platform android welcome |
| Test specific file | ./scripts/run-local-test.sh --platform android ./test/specs/welcome.e2e.js |
| Run all tests | ./scripts/run-local-test.sh --platform android all |
| Test from artifact | ./scripts/run-local-test.sh --platform android --build-from-artifact URL welcome |
| List all tests | ./scripts/run-local-test.sh --list all |
| List suite tests | ./scripts/run-local-test.sh --dry-run welcome |
Java 17 is required for Android development. Java 24+ is NOT compatible.
brew install --cask zulu@17sudo apt update
sudo apt install openjdk-17-jdkjava -version
# Should show: openjdk version "17.x.x"
echo $JAVA_HOME
# 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:
- macOS:
$HOME/Library/Android/sdk - Linux:
$HOME/Android/Sdk
- macOS:
# Download command-line tools from https://developer.android.com/studio#command-tools
# Extract to appropriate directory
# macOS
mkdir -p ~/Library/Android/sdk/cmdline-tools
cd ~/Library/Android/sdk/cmdline-tools
# Move extracted files to 'latest' directory
# Linux
mkdir -p ~/Android/Sdk/cmdline-tools
cd ~/Android/Sdk/cmdline-tools
# Move extracted files to 'latest' directory
# Install required components
sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"
sdkmanager "system-images;android-34;google_apis;arm64-v8a"
sdkmanager --licensesAdd to your ~/.zshrc or ~/.bashrc:
# macOS
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
# Linux
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/binReload your shell:
source ~/.zshrc # or source ~/.bashrcadb --version
# Should show Android Debug Bridge version
emulator -list-avds
# 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
# Create emulator
avdmanager create avd -n Pixel_8_API_34 -k "system-images;android-34;google_apis;arm64-v8a" -d "pixel_8"
# List emulators to verify
emulator -list-avds
# Start emulator
emulator -avd Pixel_8_API_34# macOS
brew install node@20
# Linux (Ubuntu/Debian)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs# Install Appium globally
npm install -g appium@3.1.1
# Install UiAutomator2 driver for Android
appium driver install uiautomator2
# 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"
-
Verify Connection:
adb devices # Should show your device with "device" status
The primary way to run tests on Android:
# Run specific test suite
./scripts/run-local-test.sh --platform android welcome
# Run all tests
./scripts/run-local-test.sh --platform android all
# Run specific spec file
./scripts/run-local-test.sh --platform android ./test/specs/welcome.e2e.js
# Build and run (when you've made app changes)
./scripts/run-local-test.sh --platform android --build welcome
# Download APK from artifact URL and run tests
./scripts/run-local-test.sh --platform android --build-from-artifact https://example.com/app.apk welcome
# Use verbose output for debugging
./scripts/run-local-test.sh --platform android --verbose welcome
# List all available tests (without running)
./scripts/run-local-test.sh --list all
# List tests for a specific suite
./scripts/run-local-test.sh --dry-run spotlightFrom the app directory:
# Set platform environment variable and run tests
cd app
npm run test:e2e:android
# Run specific suite
PLATFORM_NAME=Android npx wdio run wdio.conf.js --suite welcomeFor more control over the process:
# 1. Build and deploy the app
./scripts/deploy-android.sh
# 2. Start Appium server (in separate terminal)
appium --address 127.0.0.1 --port 4723
# 3. Run tests
cd app
export PLATFORM_NAME=Android
npx wdio run wdio.conf.js --suite welcomeUse the automated environment setup script for easy configuration:
# Setup environment for Android
source ./scripts/setup-test-env.sh --platform android
# Start an emulator by name
source ./scripts/setup-test-env.sh --platform android --start-emulator "Pixel_8_API_34"
# Start Appium server with inspector plugin
source ./scripts/setup-test-env.sh --start-appium
# Stop Appium server
source ./scripts/setup-test-env.sh --stop-appium
# List available emulators
source ./scripts/setup-test-env.sh --list-emulatorsAvailable Options:
--platform <ios|android>: Set the target platform (default: ios)--start-emulator <name>: Start emulator by AVD name--start-appium: Start Appium server with inspector plugin--stop-appium: Stop all running Appium processes--list-emulators: List available emulators--help: Show help message
List all available tests without running them:
# List all tests
./scripts/run-local-test.sh --list all
# List tests for a specific suite
./scripts/run-local-test.sh --dry-run welcomeThis is useful for discovering available tests before running them.
The setup script will automatically:
- Load values from
app/.env - Start Android emulator if requested
- Configure platform-specific Appium variables
- Set up Airtable OTP testing variables
- Display current configuration
The project includes a GitHub Actions workflow for Android E2E testing at .github/workflows/android-build-and-test.yml. The workflow:
- Runs on Ubuntu runners with KVM hardware acceleration enabled
- Sets up Android SDK and Java 17
- Creates and starts an Android emulator with optimized CI settings
- Builds the app (Release or Debug mode)
- Runs Appium tests with UiAutomator2 driver
- Uploads test results and screenshots as artifacts
- Creates a GitHub Release with the APK for easy download
- KVM Acceleration: Enables hardware virtualization for fast emulator boot
- Composite Actions: Modular
android-installandandroid-testactions for reusability - Artifact Management: APK uploaded as artifact and GitHub Release
- Airtable Integration: OTP codes retrieved for authentication testing
- ReportPortal Integration: Optional test reporting dashboard
The workflow triggers on:
- Manual dispatch via GitHub Actions UI (workflow_dispatch)
- Can be called from other workflows (workflow_call)
- Go to the Actions tab in GitHub
- Select the Android Build and Appium Tests workflow
- View test results and download artifacts
- Ubuntu with KVM is 2-3x faster and more cost-effective than macOS runners
- Windows runners lack nested virtualization support for Android emulators on GitHub Actions
- KVM provides native hardware acceleration on Ubuntu larger runners
# Find your Java installation
which java
# Set JAVA_HOME (add to ~/.zshrc or ~/.bashrc)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
# Reload shell
source ~/.zshrcThis means you're using Java 24+. Install Java 17:
# macOS
brew install --cask zulu@17
# Set JAVA_HOME to Java 17
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home# macOS
export ANDROID_HOME=$HOME/Library/Android/sdk
# Linux
export ANDROID_HOME=$HOME/Android/Sdk
# Add to PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Reload shell
source ~/.zshrc# Check if adb exists
ls $ANDROID_HOME/platform-tools/adb
# Add platform-tools to PATH
export PATH=$PATH:$ANDROID_HOME/platform-tools
# Or use full path
$ANDROID_HOME/platform-tools/adb devices# 1. Check USB cable and try different port
# 2. Ensure USB Debugging is enabled on device
# 3. Revoke and re-authorize USB debugging:
# Settings > Developer Options > Revoke USB debugging authorizations
# 4. Restart adb
adb kill-server
adb start-server
adb devices# Uninstall existing app first
adb uninstall com.softwareone.marketplaceMobile
# Then reinstall
./scripts/deploy-android.sh# 1. Check available emulators
emulator -list-avds
# 2. Start with verbose output
emulator -avd YOUR_AVD -verbose
# 3. Try with software rendering
emulator -avd YOUR_AVD -gpu swiftshader_indirect
# 4. Check if hardware virtualization is enabled (Linux)
egrep -c '(vmx|svm)' /proc/cpuinfo
# Should return > 0- Use ARM64 system image on Apple Silicon Macs
- Allocate more RAM to emulator (edit AVD settings)
- Enable hardware acceleration
- Close other heavy applications
# Install Appium globally
npm install -g appium@3.1.1
# Verify installation
which appium
appium --version# Install the driver
appium driver install uiautomator2
# Verify installation
appium driver list --installed# 1. Check device is connected
adb devices
# 2. Verify app is installed
adb shell pm list packages | grep softwareone
# 3. Check Appium logs for specific error
appium --log-level debug
# 4. Try clearing app data
adb shell pm clear com.softwareone.marketplaceMobilecd app/android
# Stop Gradle daemons
./gradlew --stop
# Clean project
./gradlew clean
# Try build again
./gradlew assembleDebugCreate app/android/local.properties:
sdk.dir=/Users/YOUR_USER/Library/Android/sdk| Variable | Description | Default/Example |
|---|---|---|
JAVA_HOME |
JDK installation path | /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home |
ANDROID_HOME |
Android SDK path | $HOME/Library/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 |
# === Device Management ===
adb devices # List connected devices
adb shell getprop ro.product.model # Get device model
adb shell getprop ro.build.version.sdk # Get Android API level
# === App Management ===
adb install path/to/app.apk # Install APK
adb install -r path/to/app.apk # Replace existing app
adb uninstall com.package.name # Uninstall app
adb shell pm list packages # List installed packages
adb shell pm clear com.package.name # Clear app data
# === Emulator ===
emulator -list-avds # List available emulators
emulator -avd AVD_NAME # Start emulator
emulator -avd AVD_NAME -no-audio # Start without audio
# === Debugging ===
adb logcat # View device logs
adb logcat | grep ReactNative # Filter React Native logs
adb shell screencap /sdcard/screen.png # Take screenshot
adb pull /sdcard/screen.png # Pull file from device
# === Appium ===
appium --version # Check Appium version
appium driver list --installed # List installed drivers
appium --address 127.0.0.1 --port 4723 # Start Appium server- APPIUM_IOS_TESTING.md - iOS testing guide
- EXTENDING_TEST_FRAMEWORK.md - Adding new tests
- TEST_ELEMENT_IDENTIFICATION_STRATEGY.md - TestID strategy