Appium from Scratch – Installing on Windows – Part 2: The Android SDK and AVDs

In this the next post in the series of “Appium from Scratch – Installing on Windows” we will look at how to get the Android SDK installed and how we can go about configuring Android Virtual Devices (AVDs) for testing on. If you haven’t checked the Appium prerequisites, then I suggest you check Part 1 of this series first. Assuming that you have all of the prerequisites installed, then let’s crack on and get Android setup on our Windows machine!

Step 1: Install the Android SDK

So, with the prerequisites installed, we next need to get hold of the Android SDK. Browse to the Android Website and download the windows.exe file as in the screenshot:

Go ahead and run the file that is downloaded. The installer should check whether the JDK is installed, although a word of warning… when I ran this the first time the installer detected a JRE (Java Runtime Environment, not a JDK!) I have quite a few different versions of the JRE and JDK installed for various projects, so i think it just reported the first one that it came across. Anyway this shouldn’t be an issue but I thought it might be worth mentioning!

The destination folder I choose for my installation was C:\Program Files\Android\android-sdk . Once the installation is completed, in that folder there is an executable file called ‘SDK Manager.exe‘. Go ahead and run that to launch the SDK manager.

Now you need to choose which packages you want to install. I choose to install the most recent current version of the SDK Tools, Platform Tools, and several previous versions of the Build Tools. I also installed the required packages for API23 and API22 . I also choose to download Intel x86 Emulator Accelerator from the Extras folder. You can see all the packages that I downloaded in the screenshots below (click on an image for a larger version):

 

If you are testing on older devices, or if your app only supports a certain version of android, you might have to install older versions here. Honestly there is a lot of debate and wide ranging information on exactly what you should install here. Some people swear that you will need to install everything if you want to avoid unusual bugs, others will say its not necessary. I will leave it to you to experiment, but if disk space isn’t much of an issue for you then I would grab more packages / versions rather than less.

Now I click Install 22 Packages, accept the license, and let the manager download the files. Likely there are quite a few files here, so it could take some time. Go and grab a coffee or something!

Once the packages have all downloaded, let’s install the Intel hardware accelerator that we downloaded from the extras section. For me, this file is location in: C:\Program Files\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager . Run the ‘intelhaxm-android.exe’, to install the accelerator. Installing this will improve the performance of the emulators, which can be sluggish (even with this, they are still slow! but it is better)

Now we need to set the ANDROID_HOME and Path Environment Variables for the Android SDK. Open environment variables (see Part 1 above, if you need a reminder how to open these, LINK TO PART 1), add a new SYSTEM VARIABLE with variable name = ANDROID_HOME and variable value = C:\Program Files\Android\android-sdk (or wherever you installed the Android SDK)

Still in Environment Variables, under SYSTEM VARIABLES, find the PATH variable and click edit. Append the values %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools to the end of the path (again, see Part 1 if you need a reminder on how to do this) and click OK.
To verify the installation, open CMD prompt and type :> android , the Android SDK manager should load. This confirms that the Android SDK has been installed successfully, good job!

Step 2: Configure one or more Android AVDs

Now let’s have a quick look at how we can actually create an AVD (Android Virtual Device) to test on! We need to launch the AVD Manager, which we can do by clicking the executable in C:\Program Files\Android\android-sdk, or just typing :> android avd in the command prompt.

Once the AVD Manager loads, click generate. Go ahead and fill in the settings as in the screenshot below:

Now you will probably want to experiment with these settings a bit to get a device and resolution that works for you, and to be optimal for your system. Feel free to play around and create a few different devices, it took me a few goes to get the one that I wanted. Just remember that this is the tool you use anytime you want to create a new Android device to test on.

With the device created, you can launch the emulator by selecting it in the list of devices and clicking ‘Start’, or from the command prompt by typing :> emulator @training01 , where ‘training01‘ is whatever you called the emulator. Depending on your system it will probably take a little while to load (especially the first time), but eventually it should load and you now have a pretty much fully functional Android device to play with. Nice!

That’s it! We now have everything in place to finally install Appium! That wasn’t hard at all (hopefully…). In the next post, we will run through how to install Appium, both through the executable and so that we can run it from the command line. See you there!