Testing Android applications on PC or Mac without a physical device can be quite a burden. The configurable Android virtual machines in Eclipse/Android Studio are notably sluggish and don’t work well with many third party frameworks, especially those powered by C++. If your development machine has Intel-based hardware you can accelerate the emulation process by using Intel® HAXM technology, but AMD users are not yet so lucky.
The fastest and easiest way I’ve found to test Android applications is via the BlueStacks app player. BlueStacks is a free, ad-supported product for PC and Mac that enables you to download and run Android applications from your PC, as if using an Android device itself. BlueStacks isn’t the only product on the market of its kind, but it does boast higher compatibility and a greater feature set than the competitors. According to BlueStack’s feature chart, it supports up to 96% of all apps and 86% of all games on the Android market. Furthermore, BlueStacks offers streamlined emulation of the Android device’s camera, microphone, multitouch and more which makes it ideal for testing in-development apps.
Installing Android Debug Bridge (ADB)
To use BlueStacks for debugging Android apps, you’ll want to make sure you have the Android Debug Bridge (ADB) installed and operational. Some unofficial packages exist to get ADB in a hurry, but I have not tested said packages personally and it is easy enough to get it up and running through official means.
- If you haven’t already done so, download and install the Android SDK Tools package from Google. ZIP files are offered for Windows, Mac and Linux; extract the contents to a dedicated directory.
- From the extracted file location, launch SDK Manager.exe. Under Tools, check the box to install “Android SDK Platform-tools” and press the Install button. You will then have to click “Accept License” and then “Install” to download and install these components.
- Once installed, you will find ADB.exe within the “platform-tools” subfolder of the location you extracted the original files to. You can run this file from the command prompt without any parameters, or visit its official page on Google, to review the multitude of available settings. I recommend that you also append the ADB location to the PATH environmental variable [assuming it is a Windows install] so that it can be ran from any command line prompt without having to navigate into the folder directly.
- Press Windows Key + Pause/Break on your keyboard to get to the System Information screen.
- Click on Advanced System Settings in the left menu.
- Click the Environment Variables button.
- Double click the Path entry under System Variables.
- Go to the end of the field and make sure there is a semicolon (;), then insert the full platform-tools path (i.e., C:\android-sdk\platform-tools\)
- Click OK three times to close out of the dialog windows.
- Now if you have a physical Android device attached to your computer (with USB Debugging enabled), you should be able to type ADB devices from the command prompt to see a list of available devices for testing [the ADB daemon will start automatically with this command if it is not already started].
Installing BlueStacks App Player
Installing and configuring BlueStacks is as easy as installing any computer application.
- Head on over to http://www.bluestacks.com/ and click the Download button, which will match your target platform (Mac or Windows).
- Once downloaded, launch the EXE and follow standard install procedure on Windows, or double-click/drag the app file to your Applications folder on Mac.
- When you first launch BlueStacks, you will be taken through an initial configuration screen much like when booting a new Android tablet.
- You will want to sign-in using a Google account in order to access the Google Play store and synchronize app data and settings.
- When all is said and done, you’ll be at a landing page with easy access to your Android applications.
Running Development Apps Through BlueStacks
With ADB and BlueStacks installed, all that remains is to connect ADB to the BlueStacks player and send your Android app to it. Note that the free version of BlueStacks is ad/app supported so you may occasionally be prompted to install promoted apps before continuing. Alternatively, you can buy a year-long license for $24, the full version can also enhance performance.
- Launch BlueStacks so that the main dashboard screen is visible.
- Open a command prompt (or terminal on Mac) and enter: adb connect 127.0.0.1 then press Enter. This will connect the BlueStacks player as a device on port 5555 by default. If the ADB command does not work, chances are you didn’t set your path variable correctly; you can navigate to the platform-tools folder and run the adb command from there instead.
- From within Eclipse or Android Studio, click the Run or Debug button. This should open up the Android Device Chooser window where you will see the BlueStacks player and any other physical devices connected to the computer. Select the correct option and hit OK. The app should transfer to BlueStacks very quickly and will run much more fluidly than the default virtual machines!