Beginner’s Guide to Setting Up Mobile Automation for Android

 Mobile automation has become a crucial part of modern software QA. With mobile apps used for banking, travel, e-commerce, education, and more, ensuring reliable performance on real devices is essential. This blog walks you through the core steps required to set up a mobile automation environment for Android, covering device configuration, tool setup, environment variables, and basic inspection techniques.


1. Install Java (JDK 8u111 Recommended)

Mobile automation tools rely heavily on Java.
Start by downloading:

Java SE Development Kit (JDK 8u111)

After installation, configure the environment variable:

Set JAVA_HOME

  1. Open Environment Variables on your system.

  2. Under System Variables, click New.

  3. Add: JAVA_HOME = C:\Program Files\Java\jdk1.8.0_111

  4. Edit the Path variable and add: %JAVA_HOME%\bin

This ensures Java commands run globally on your machine.

2. Install Android Studio

Android Studio includes the Android SDK, which is required for automation tools to interact with Android devices.

After installation:

Verify that the SDK directory exists at: C:\Users\<YourUser>\AppData\Local\Android\Sdk

You will also need the Android Studio bin folder: C:\Program Files\Android\Android Studio\bin

This allows tools like studio64.exe to run, and ensures the SDK Tools folder becomes visible.


3. Install Node.js

Mobile automation frameworks like Appium run on Node.js.

Steps:

  1. Download Node.js LTS version.

  2. Install normally.

  3. Confirm installation with: 

    node -v

    npm -v

4. Configure Environment Variables

Setting up environment variables ensures that automation tools such as adb, emulator, sdkmanager, and Appium can run from any command line window.

ANDROID_HOME

Create a system variable: ANDROID_HOME = C:\Users\<YourUser>\AppData\Local\Android\Sdk

Add the Following to PATH

Under System Variables → Path → Edit, add:

%ANDROID_HOME%

%ANDROID_HOME%\platforms\android

%ANDROID_HOME%\platform-tools

%ANDROID_HOME%\tools

%ANDROID_HOME%\tools\bin

C:\Program Files\Android\Android Studio\bin

These provide access to adb, platform tools, AVD tools, Android build tools, and SDK utilities.


5. Enable Developer Mode on Your Android Device

To run automation on a real device, enable:

Developer Options

  • Go to your device settings.

  • Tap Build Number repeatedly until Developer Mode is activated.

Enable the following toggles:

  • USB Debugging

  • Stay Awake

  • (Optional) Disable Verify Apps Over USB
    This avoids interruptions during testing.

6. Verify Device Connection using ADB

Connect your mobile using USB and run: adb devices

device ID (UDID) should appear, confirming communication.

If unauthorized:

  • Check the device screen for a USB Debugging Authorization popup.


7. Identify App Package & Activity (For Automation Launch)

To automate an installed app:

  1. Open the app on the device.

  2. Run: adb shell dumpsys window | findstr mCurrentFocus

This returns:

  • appPackage

  • appActivity

These are required to launch the app during automation.

8. Define Desired Capabilities

A typical capability set for Android automation looks like:

{

  "platformName": "Android",

  "platformVersion": "12",

  "automationName": "UiAutomator2",

  "udid": "<your-device-udid>",

  "appPackage": "<your-app-package>",

  "appActivity": "<your-app-activity>"

}

Capabilities help automation tools understand:

  • Which device to use

  • Which app to open

  • Which automation engine to run

9. Inspect Mobile Elements

Use any standard mobile inspector tool to identify:

  • IDs

  • Accessibility labels

  • Class names

  • XPaths

  • View hierarchy

This is essential for writing stable automation scripts.

Inspectors allow actions like:

  • Hover to highlight UI elements

  • Copy ready-made locators

  • Validate locators using a search function

10. (Optional) Use a Screen Mirroring Tool

A mirroring tool helps interact with a real phone directly from your computer.

Benefits:

  • Easy to navigate the device during inspection

  • View the mobile UI clearly

  • Record manual steps before automation

  • Capture locators quickly


Conclusion

Setting up the environment correctly is the most crucial step in mobile automation.
Once Java, Android Studio, Node.js, and environment variables are configured and your device is ready, you can smoothly begin automating:

  • UI flows

  • End-to-end journeys

  • Regression test suites

  • Performance-critical scenarios

This setup is universal and works with tools such as:

  • Appium

  • Detox

  • Espresso (with minor changes)

  • Custom Python/Java automation frameworks

Comments

Popular posts from this blog

Hybrid Framework Flow: Keyword + Data-Driven

Which Framework is Best: Data-Driven or Keyword-Driven?