Appium: Setup Android Environment Variables Part 2

— 2 min read

Prerequisite: In order to setup environment variables you should have installed ANDROID SDK (Studio) (see link)

 

Windows setup

 

Find the folder location where you installed Android SDK

In the first step we will try to find the folder path where we have installed Android SDK –

  1. The default folder location where Android SDK is installed is – C:\\Users\\#####\\AppData\\Local\\Android\\sdk.

Please open this folder path and see if you have Android SDK folder in there with contents as shown below. Be aware that the AppData folder is hidden. You need to unhide this in windows!

Android Windows Install

  1. Copy the SDK folder location: In my case: C:\\Users\\xxxxx\\AppData\\Local\\Android\\sdk

  2. Setup the Android environment variablesGo to the windows environmental variables and add android_home, enter Android_Home: C:\\users\\xxxx\\AppData\\local\\Android\\sdk

Learn Automated Testing: Environmental Variables to setup AppiumLearn Automated Testing: Android Environmental Variables Windows

Then add the platform-tools,tools and tools\bin to the path variable like this:

Learn Automated Testing: Android Environmental Variables Windows

  • %ANDROID_HOME%\platform-tools
  • %ANDROID_HOME%\tools
  • %ANDROID_HOME%\tools\bin

Verify that Android Environment Variables have been set correctly

To verify that all the Android Environment Variables are correctly setup, open command prompt and run this command: sdkmanager – -list

Note: I used jdk 8.241 to avoid errors with android studio starting the sdkmanager –list, if you face issues I would advice to install this version for now.

When that is working start Uiautomatorviewer in the commandline ( Appium is calling  uiautomator via an api which in which you can record your automated testscripts). If everything is working as expected we can start Appium

Learn Automated Testing: uiautomator

Config for mac Os

If you use a mac os;

Start a terminal then type in the following

export ANDROID\_HOME=/Applications/ADT/sdk

Add this to the PATH environment variable

export PATH=$PATH:$ANDROID\_HOME/platform-tools

If the terminal doesn’t locate the added path(s) from the .bash_profile, please run this command in terminal

source ~/.bash\_profile