Developing Android Applications with Adobe AIR [11]
On Windows, most Android devices require drivers to communicate with the Android SDK. Instructions for installing these drivers are available on the Android developer website at http://developer.android.com/sdk/win-usb.html. If you have difficulty updating Google’s USB driver package, try to manually edit the android_winusb.inf file in the Android SDK.
Alternatively, with the SDK open, go to Available Packages, select “USB Driver package, revision 3”, and click Install Selected. Note that the location of the packages may change with new upgrades. For instance, in newer versions, the packages can be found under Available Packages→Third party add-ons→Google USB driver package, revision 4.
Note that with AIR 2.6, Adobe made the process much easier by bundling the Android USB drivers for most Android devices on Windows.
We will use what is inside the tools folder.
NOTE
If you don’t know how to use the command line, read the section Using the Command-Line Tool.
Installing the Android Debug Bridge
ADB is composed of a client that consists of your application, a daemon running on the device or emulator, and a server which runs in the background on your development machine and manages the communication between the client and the daemon. You can read more about it at http://developer.android.com/guide/developing/tools/adb.html.
To install an Android application using ADB, type the following at the command prompt:
androidSDK/platform-tools/adb install hello.apk
To install ADB in debug mode or for the emulator, provide a destination:
androidSDK/platform-tools/adb -d install hello.apk
androidSDK/platform-tools /adb -e install hello.apk
Let’s look at how to test and debug using ADB.
Detecting Your Device
Connect your device to your computer’s USB port. Turn on USB storage when prompted, or by exposing the option from the top slide-down menu. Set your device for development by turning on USB debugging under Settings→Application→Development.
In the Terminal window on the Mac, or at the command prompt on Windows, type the following to determine whether the SDK sees your device:
androidSDK/platform-tools/adb devices
If the SDK detects your device, it will return the ID for it as follows:
List of devices attached
HT019P805406 device
If it does not detect your device, kill the ADB server and restart it:
androidSDK/platform-tools/adb kill-server
androidSDK/platform-tools/adb start-server
If all else fails, restart your computer. Once your device is detected, you can start using some of the Android tools.
Using the Dalvik Debug Monitor
You can use the Android Dalvik Debug Monitor (DDM) to test the Android application on your desktop. To launch the GUI, navigate to the ddms file under Android→Tools→ddms (ddms.bat on Windows) and double-click it.
You can take device screenshots from live running applications at your device’s resolution, which is very handy for documentation. On the console, select Device→Screen Capture. Click Refresh every time you want to see an update of your device screen. The images are recorded at your device screen’s resolution.
Selecting Device→File Explorer exposes some of the device’s nonprivate file structure, as well as options to pull, push, or delete files on the device.
DDM handles a range of other tasks as well, such as log dumps, thread views, phone call simulation, and memory and performance profiling. You can read more about it at http://developer.android.com/guide/developing/tools/ddms.html.
Using the logcat Command
The ADB logcat command provides a mechanism for grabbing information from the device and dumping it via USB onto a log screen. Use it to view ActionScript