test-suite
2024.10
true
UiPath logo, featuring letters U and I in white
Test Suite User Guide
Automation CloudAutomation Cloud Public SectorAutomation SuiteStandalone
Last updated Nov 11, 2024

Local Android devices

Setting up local Android devices

To set up a local device to work with the Mobile Automation activities, you need to run a local instance of Appium, and have the necessary tools to automate Android devices.

There are two types of local Android devices that you can automate:

  • Physical - a physical Android device that you can connect to your local machine, through a USB cable.
  • Emulator - an emulator for an Android device that's stored locally.

Most used Appium commands

The list below describes the most used commands for setting up Appium in the context of Mobile Device Automation:

  • appium driver list - lists installed drivers (recommended for Appium 2.0)
  • adb devices - lists the connected devices
  • adb start-server - starts debugging server
  • adb kill-server - stops the debugging server
  • ctrl + c - kills Appium
  • appium-doctor - helps in debugging your Appium.

Application Storage

You will need to store your mobile apps on the same machine where your Appium server is running, or upload the APK or IPA file to an URL that is anonymously accessible by the Appium server (e.g. Blob storage).

Installing applications from the Play Store or App Store is not possible, except if you manually automate these applications to install your specific application.

Configuring Local Physical Android Device

Prerequisites

Follow the steps below to complete the prerequisites for configuring a local physical Android device:

  1. Download and install Java. You can download Java through a zip file here.
  2. Download and install Node.js. You can download the latest version of Node.js here.
  3. After the installation of Node.js is finished, open a command prompt and check if it was successful, using the following commands:
    • node-v - returns the Node.js version installed on your machine. The version returned needs to be equal to, or higher than 19.
    • npm-v - returns the version of npm installed on your machine. The version returned needs to be equal to, or higher than 8.
  4. Download and install Android Studio. You can download Android Studio here.
  5. Install Android SDK Tools (Obsolete) using Android Studio.
  6. In Windows, navigate to Advanced system settings > Advanced > Environment Variables.
  7. Under System variables click New and configure the following variables:

    a. JAVA_HOME variable. Points to the folder where Java was installed.

Variable name: JAVA_HOME.
Variable value: the path where the JDK is located on your machine. For example: C:\Program Files\Java\jdk8.

b. ANDROID_HOME variable. Points to the folder where Android SDK was installed.

Variable name: ANDROID_HOME Variable value: the path where the Android SDK is located on your machine. For example: C:\Users\Username\AppData\Local\Android\Sdk Note: The Username part, inside the Variable Value path, must be replaced with the actual name of the user operating on the machine.
Important: If Java is updated automatically, you need to manually configure this variable with the updated path.


  1. Open the Node.js command prompt and install Appium:

    • For Appium 1.0, run the following command: npm install -g appium. Appium 1.0 comes with all drivers installed.
    • For Appium 2.0, run the following command: npm install -g appium@next.
Appium 2.0 comes without the drivers installed. Therefore, to install the needed drivers, also run the following command: appium driver install uiautomator2.

For more information on Appium 1.0 configuration, see Quick Start Intro.

Note: We recommend using Appium 2.0 with Mobile Automation version 22.10 or higher.
  1. Restart the computer to apply the changes.
  2. Open the physical mobile device, and enable Developer Options.

    • On your phone, navigate to Settings > Developer Options.
    • Under the Networking section, open Default USB configuration and set it to Charging phone only.
  3. Enable USB debugging.
  4. On your phone, navigate to Settings > Developer Options.
  5. Under the Networking section, open Default USB configuration and set it to Charging phone only.

Configuring Local Physical Android Device

  1. Connect the physical device to the local machine, using a USB cable.
  2. Open a command prompt, and start the debugging server, using the following command: adb.exe start-server.
  3. Allow USB debugging on the mobile device (if you're asked to allow it).
  4. Manually add the --base-path /wd/hub parameter before starting the Appium session.
  5. Start the Appium server, using the following command: appium -p 10001 --relaxed-security --allow-insecure chromedriver_autodownload.
    Note:
    • If the auto-download fails, you can point to an already downloaded chromedriver.exe, by concatenating the following command:

    --chromedriver-executable "path_to_chromedriver"

    • Make sure to leave the Appium server connection running without any interferences. For example, if you click within the terminal, the communication is cut off, which may lead to a communication error in Mobile Device Manager.
  6. Add the configurated local physical Android device in Mobile Device Manager, using the Adding Local Android Device in Mobile Device Manager procedure.

Configuring Local Emulated Android Device

Prerequisites

  1. Download and install Java. You can download Java through a zip file here.
  2. Download and install Node.js. You can download the latest version of Node.js here.
  3. After the installation of Node.js is finished, open a command prompt and check if it was successful, using the following commands:
    • node-v - returns the Node.js version installed on your machine. The version returned needs to be equal to, or higher than 19.
    • npm-v - returns the version of npm installed on your machine. The version returned needs to be equal to, or higher than 8.
  4. Download and install Android Studio. You can download Android Studio here.
  5. In Windows, navigate to Advanced system settings > Advanced > Environment Variables.
  6. Under System variables click New and configure the following variables:

    a. JAVA_HOME variable. Points to the folder where Java was installed.

Variable name: JAVA_HOME.
Variable value: the path where the JDK is located on your machine. For example: C:\Program Files\Java\jdk8.

b. ANDROID_HOME variable. Points to the folder where Android SDK was installed.

  • Variable name: ANDROID_HOME
  • Variable value: the path where the Android SDK is located on your machine. For example: C:\Users\Username\AppData\Local\Android\Sdk
    Note: The Username part, inside the Variable Value path, must be replaced with the actual name of the user operating on the machine.
    1. Open the Node.js command prompt and install Appium:
  • For Appium 1.0, run the following command: npm install -g appium. Appium 1.0 comes with all drivers installed.
  • For Appium 2.0, run the following command: npm install -g appium@next.
Appium 2.0-beta comes without the drivers installed. Therefore, to install the needed drivers, also run the following command: appium driver install uiautomator2.

For more information on Appium 2.0 configuration, see Quick Start Intro.

Note: We recommend using Appium 2.0 with Mobile Automation version 22.10 or higher.
  1. Restart the computer to apply the changes.

Creating Android Emulator

Create your Android emulator using Android Studio.

  1. Open Android Studio.
  2. Click Configure and select SDK Manager from the dropdown.
  3. Uncheck Hide Obsolete Packages and make sure that Android SDK Tools (Obsolete) is selected.


  4. Click Apply and then Ok to close.
  5. Navigate to Configure > AVD Manager to configure a virtual device. For more information, see Create and manage virtual devices.


  6. Update your device's Google apps.

Enabling Web and Hybrid Automation With WebDriver

Enable WebView debugging on the local device to allow Mobile Device Manager to recognize the majority of UI elements inside an application.

If Appium doesn't autodetect the Chrome or the WebView version on your Android, choose one of the options below:

  1. Use the --allow-insecure chromedriver_autodownload command. This enables Appium to automatically detect and download the ChromeDriver version that corresponds to your environment.
  2. Manually specify and download the WebDriver for Chrome:

    2.1. Open your device in Android Studio.

    2.2. Navigate to Settings > Apps & notifications.

    2.3 Click See all apps.

    2.4. Click the vertical ellipsis button and select Show system from the dropdown.

    2.5. Use the search function to look for Android System WebView.

    2.6. Open the app and go to Advanced.

    2.7. Copy the version number at the bottom of the screen.

    2.8. Download WebDriver for Chrome and consider the following:

    • Select the version that corresponds to the Android System Webview version from the previous step, and extract it to a folder.
    • You are looking for an exact match for the version (major.minor.patch.revision).
    • In case an exact match isn't available, use the latest major version of ChromeDriver that matches the major version of the Android System Webview.
    • If you want to automate the Chrome app just perform the same steps from above and keep a note of the Chrome version instead.
  3. Add the configured local emulated device in Mobile Device Manager, using the Adding Local Android Device in Mobile Device Manager procedure.

Adding Local Android Device in Mobile Device Manager

  1. Open MDM from Studio.
  2. In the left navigation panel go to Devices.
  3. Configure your device as follows:
    • Name - Enter a name to identify your device in the Devices tab.
    • Appium URL - Enter the localhost. For example: http://localhost:10001/wd/hub.
    • Platform - Click the field to select Android from the dropdown.
    • Device Name - Enter the device name. One way to see that is through Android Studio if you navigate to Configure > AVD Manager, and then go to More Actions > View Details.
    • Platform Version - Add the version number of your Android OS.
    • Additional Desired Capabilities (Optional) - Add specific capabilities to customize your automation session.

      Important: To activate the previously installed Appium drivers, add the following capability to the Additional Desired Capabilities section:

      Name

      Value

      appium:automationName

      UiAutomator2

      For more information, see Appium Desired Capabilities.

  4. (Optional) - Set your device location in the Location tab, to test applications that use Location Services to generate location data.


  5. (Optional) Configure logging and video recording details in the Logging tab.
  6. (Optional) Configure your development process in the Development tab.
    • Close Similar Tabs (Activated by default): Close tabs running connections with similar devices and applications.
    • Wait for Page Update (Activated by default): Wait for the page source to retrieve a screenshot of each action.
  7. Click Save & Close to add your device.

    Your device is added to the Devices list. To add a local device, see .



Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.