Sencha Touch applications developed for Android devices should be tested in the Android simulator as part of your development process. This blog post discusses how to install and use the Android simulator, for Sencha Touch applications developed with either the command line tools or Sencha Architect
The number of Android smartphones being sold and used has recently surpassed iOS smartphones. (This Time magazine article from April 2013 breaks down the numbers).
Many Sencha Touch developers are targeting the Android platform. This blog post will show you how to set up an Android development environment from start to finish. The screenshots and directory names are Mac-centric. The process for Linux is almost identical, and the process for Windows is very similar.
1. Install Android SDK Tools
Install the Android SDK Tools: download the proper file for your operating system.
On the download page, click the dropdown for “Download for Other Platforms” and download the “SDK Tools Only” zip file for your operating system. (For Windows, download the zip file, not the installer.exe).
What you’re downloading is not the SDK itself, but a zip file that contains the installer for the rest of the SDK. We will use the SDK tools to download the actual emulator in the next section.
Unzip the Android SDK Tools to the “bin” directory in your home directory, which you may have to create.
For Mac OS, save the file to /Users/username/bin (create the “bin” directory if it doesn’t exist). The full path to your Android SDK directory on Mac is /Users/username/bin/android-sdk-macosx/.
For Linux, save the file to /home/username/bin (create the “bin” directory if it doesn’t exist). The full path to your Android SDK directory on Linux is /home/username/bin/android-sdk-linux/.
If you’re using Windows 7, Windows puts your personal files in the directory C:\Users\username. If you’ve already installed Sencha Cmd (see below), the C:\Users\username\bin directory has already been created for you, otherwise you can create it. Unzip the Android SDK under the bin directory. For Windows, the full path to the Android SDK is C:\Users\username\bin\android-sdk-windows.
2. Install the Android emulator
Using the Android SDK Manager (that you just downloaded), install the Intel-based Android emulator.
In the Android SDK directory, under the “tools” subdirectory, you’ll find an executable file called “android”. Double-click on it to launch the Android SDK Manager.
Uncheck the box next to “Android 4.2.2 (API 17)”. This will uncheck all the boxes in that section. The only box you need to check is “Intel x86 Atom System Image”. You can leave the checkboxes next to “Platform tools” and “Build-tools” checked if you want.
Since we are using Sencha Touch to develop our Android apps, we don’t need to install any of the other products.
Here are the final steps to finish the install:
- Click “Install 4 packages…” to download and install your Android packages.
- Click on the package headers, and click “Accept License”.
- The progress bar at the bottom will show you the progress of the install. Wait until all your packages have been installed.
3. Configure and start up the Android emulator
To test our emulator download, we’ll configure the emulator for its first run, then start it up to see if it’s working properly.
After all your packages have downloaded in the previous step, select the “Tools → Manage AVDs…” menu item in the Android SDK tools.
A dialog will appear showing you all the virtual Android machines that you’ve defined. Since this is the first time that you’ve run this command, there are no machines shown. Click the “New…” button to define a new machine.
Fill in the name, type of device, and the API level (17 in our case). Also, make sure the “Use Host GPU” checkbox is checked. Click OK to accept these settings, and click OK to accept the summary screen.
You’ve configured your first Android emulator, and you should see a green check in front of your virtual Android device. On the right side of the dialog, click “Start…” to start up the emulator. On the following screen, click “Launch”.
If you’ve installed everything correctly, the Android emulator will start up. Depending on the speed of your machine, the startup process may take several minutes. When the emulator starts up, you should see the screen below.