# Setup Android Environment for Mobile Testing

# Before You Begin

# Logigear AppCenter

If you're running Windows, the easiest way setup your system for Gondola is using LogiGear AppCenter.
LogiGear AppCenter
Click here to download LogiGear AppCenter.

macOS and Linux

Currently, AppCenter is only available for Windows, but Gondola runs great on macOS and Linux, so follow the instructions below to get started. If you wish to manually install AppCenter on Windows you can also use the instructions below.

# Mobile Testing Environment Prerequisites

  • Ensure Gondola Studio is installed
  • For Android testing, it requires a Windows, OS X or Linux machine for hosting test. For iOS testing, OS X is required
  • Your app's .apk or .ipa file or its appPackage name (e.g. com.google.android.youtube) and appActivity name if you are going to test pre-installed applications.

# Setup Android Environment

# Installing JDK

  1. Download the proper installation file from Oracle for your operating system. Java SE Development Kit 11.0.5 LTS is recommended.
  2. Run the installer, then wait until the installation is complete. JDK Installed

Set JAVA_HOME in your system’s environmental variables to the JDK installation path.

  1. PATH variable configuration: Add the JDK bin folder path to your system’s environment variable PATH (or Path on Windows 10). You'll need to intialize this variable using the same method you used for the JAVA_HOME variable if you have not already done this.

    On the other hand, you just have to edit by click Edit button after select it and add new value %JAVA_HOME%\bin by click New button (for Windows). On OS X, depend on the system default shell that you have to add new line export PATH=$PATH:$JAVA_HOME/bin to ~/.zprofile or ~/.bash_profile file. For Linux, users have to add new line export PATH=$PATH:$JAVA_HOME/bin to ~/.bashrc.

  2. Run source ~/.bash_profile or source ~/.zprofile (for OS X) and source ~/.bashrc (for Linux) or restart the machine. Remember to run these commands (or restart) everytime you modify these files. Windows users don't need to do this step.

TIP

For instructions on setting up the JDK, please refer to Oracle's JDK Installation guide.

# Installing Android Studio

Android Studio is an IDE for creating Android applications. The Android SDK tools are included when you install Android Studio.

TIP

If you don't want to install Android Studio, you can download the basic Android CLI tools which come with the sdkmanager. However, Android Studio is the recommended choice as it's easier to set up.

  1. Go to the Android Studio website and click Download Android Studio.
  2. Run the application file (e.g. android-studio-ide-182.5314842-windows.exe).
  3. In the Choose Components screen, select both the Android Studio and Android Virtual Device components.
    Android Studio Choose Components
  4. Configure your settings, then click Install to start the installation process.
  5. Click the Finish button on the Completing Android Studio Setup screen to finish the process.
    Finish installing Android Studio

# Installing Android SDK Tools

After installing Android Studio, you'll need to install Android SDK Tools in order to use Appium.

When launching Android Studio for the first time, the setup process will start and ask if you want to install the required Android SDK Tools (If you've already set up Android Studio go to Step 6) :

  1. Launch Android Studio
  2. Android Studio Setup Wizard will be displayed like below Android Studio Setup Wizard
  3. Click Next, then select Standard on the Install Type screen
  4. Continue navigating to Verify Settings, you will see the list of SDK Components to be downloaded

TIP

The items in the list depend on the current version of Android Studio. If you already have an older version installed, the list might be different.

  1. Click the Finish button and then wait until the installation is completed.

  2. If you've already set up Android Studio, open up the SDK Manager by selecting Configure > SDK Manager from the menu bar.
    Android SDK Manager

  3. Select Android SDK > SDK Tools
    Android SDK Tools

  4. Ensure that the components below have been installed or updated:

    • Android SDK Build-Tools (version 29.0 is recommended)
    • Android Emulator
    • Emulator Accelerator (if available)
  5. Configure the ANDROID_HOME environmental variable: Initialize this variable using the same method you used for the JAVA_HOME environmental variable.

# Checking the adb command

Android Debug Bridge (adb) is a powerful tool that's provided as part of the Android SDK. With adb, you can run commands and communicate with connected devices or emulators.

First, you can check whether adb has been installed with adb devices command:

adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully

If you get the daemon started successfully message, then adb is installed and is working properly.

If the command adb devices fails to run (like in the Windows example below), please follow the next TIP.

adb devices
'adb' is not recognized as an internal or external command,
operable program or batch file.

TIP

You have to add path to <platform-tools> folder to your PATH variable to run adb command from any directory.

For Windows, users have to add C:\Users\[username]\AppData\Local\Android\Sdk\platform-tools to your PATH using the same method you used for installing the JDK

On OS X just add this :<path to platform-tools folder> to the line that contains the PATH variable value in .zprofile or .bash_profile. The whole line should look like this : export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/platform-tools or export PATH=$PATH:$JAVA_HOME/bin:/Users/test/Library/Android/sdk/platform-tools in case ANDROID_HOME wasn't set.

On Linux you have to add :<path to platform-tools folder> to the PATH variable by using either of these commands: export PATH=$PATH:$JAVA_HOME/bin:$ANDROID_HOME/platform-tools or export PATH=$PATH:$JAVA_HOME/bin:~/Android/Sdk/platform-tools

adb is included in the Android SDK Platform-Tools package. If it hasn't been installed yet, you can install adb via the SDK Manager in Android Studio as above.

TIP

For advanced adb usage, please refer to Android Debug Bridge (adb)

# Creating an Android Virtual Device (AVD)

An AVD is a configuration that defines the characteristics of an Android device that you want to simulate using the Android Emulator.

  • Launch Android Studio
  • Select Configure > AVD Manager

AVD Manager

  • Click Create Virtual Device

Select Hardware

  • In the Select Hardware window, select a hardware profile then click Next.

    Note: If you're unable to find your hardware profile here, you can use the New Hardware Profile or Import Hardware Profile feature.

  • In the System Image window, select the Android version, then click Next.

Select System Image

Note: If you haven't already, you'll need to download a system image in order to run it on a virtual device. Click Download to download an image. An internet connection is required to complete the process.

  • Review your settings in Verify Configuration, make any modifications if needed, and then click Finish.
  • Your new AVD will be shown in the Your Virtual Devices screen.

# Starting The Android Emulator

The Android Emulator simulates an Android device on your computer so that you can test your application on a variety of devices and Android API levels without a physical device.

To install or check whether you've installed the Android Emulator, refer to the section on Installing Android Studio.

To start the emulator,

  • Launch Android Studio
  • Select Configure > AVD Manager
  • Select the AVD you want to use, then click Run

Your Virtual Devices Screen

  • The Android Emulator appears.

Android Emulator

# Installing Appium Server

Appium Server is required for testing on mobile, users can choose between installing it via npm or the Appium Desktop package which contains:

  • Appium Server, the software driving the test automation
  • A GUI to start Appium Server and inspect mobile applications.

Note: Appium Desktop only runs on 64-bit systems. If you're using a 32-bit (x86) system, please skip to the TIP below.

Click here to download and install the right package for your OS (version 1.17 is recommended). Typically:

  • For Windows: it should look like Appium-windows-....exe
  • For Mac: download the one with .dmg extension
  • For Linux: download the one with .AppImage extension

TIP

Only Appium Server is required for running tests, you can install Appium Server by following the instructions here instead of installing the Appium Desktop package.

# Appium Desktop

Now open Appium Desktop and click the Edit Configurations button.

  • ANDROID_HOME: Set this to your Android SDK folder. It is usually one of these

    • Windows C:\Users\<UserName>\AppData\Local\Android\Sdk\
    • Linux /home/<UserName>/Android/Sdk/
    • OSx /Users/<UserName>/Library/Android/sdk/
  • JAVA_HOME: Set this to the location of your java installation

    • Windows C:\Program Files\Java\jdk-<VERSION NUMBER>\
    • Linux /usr/lib/jvm/java-<VERSION NUMBER>-openjdk-amd64
    • OSx /usr/libexec/java_home

Appium Settings

Save the settings and restart Appium Desktop.

# Appium Server with Command Line

If you choose not to use Appium Desktop, Appium Server has to be installed using the command line. You also have to use the command line to configure and control it. Follow the steps below to install Appium Server using the command line:

  1. Ensure that NodeJS is installed
  2. Open the command line and install Appium using npm
   npm install -g appium

Before running a test, users need to start Appium Server by running appium from the terminal. If you encounter a PSSecurityException after executing appium command, please follow the steps here.

TIP

Use Appium Doctor to verify your Appium installation.

# What's Next

Now, we're ready to start mobile testing with Gondola! Continue to the Mobile Testing Tutorial to learn how!

Last Updated: 3/1/2021, 4:42:04 AM