Testing Android Applications on Multiple Platforms

There are times when I actually envy iPhone developers! With a very limited number of version / screen size combinations, testing is relatively straightforward. The very same thing that has made the Android platform so successful: near endless variety of hardware makes testing a serious challenge.

In an ideal world we would test Android apps on every possible combination of hardware and operating system version. Given the massive diversity of the Android ecosystem this is simply not an option. How then should we tackle this challenge?

One option is to target a very small set of devices / versions which are supported by your application and test against this set. The Play store (formerly known as the Android Market) supports this by hiding Apps which will not run on a consumer’s device. The problem with this approach is that you are limiting potential sales to a fragment of the potential market.

Most Android apps are targeted at a broader range of hardware than the developer can possible have available. How then do they do that? How can they guarantee their application will run on every platform? The answer lies in using Android Virtual Devices (AVD). AVDs allow Android devices to be emulated on a PC running Windows, Linux or OS/X.

The Android SDK provides an AVD manager tool which allows the developer to create new AVD images on which to test. The developer specifies crucial information such as which Android version to target, the screen size and resolution, the available memory and what additional hardware / sensors are available. Once created and started, the AVD appears on the desk-top of the development machine and fully integrates with the other Android development tools. The developer can then deploy their application, run it and debug it in a realistic simulation of a real device.

There are a few caveats to bare in mind:

  • Unless you have very fast hardware and are emulating a very early Android device, the emulator will run more slowly than the real device.
  • Many of the sensors will not work (as they are not present). However, many sensors, including GPS and and orientation sensors can be simulated by injecting data into the emulator.
  • If your code runs correctly within an AVD, it will probably run on a real device, but there are no guarantees.
  • The emulators for Honeycomb and ICS work very, very slowly when running on virtualized hardware.
  • The emulators are a little temperamental. When creating your own AVD images, some experimentation may be necessary to create a stable version.

If you want to find out more about testing Android applications on AVD’s, you could try Learning Tree’s Developing Applications for Android ™ Devices course. It provides a great opportunity to experiment in a controlled environment.

Mike Way

Type to search blog.learningtree.com

Do you mean "" ?

Sorry, no results were found for your query.

Please check your spelling and try your search again.