Login     Sign Up
Innocent Cyril (@admin)
4 months ago
70 Views

The Android SDK includes several tools and utilities to help you create, test, and debug your projects. A detailed examination of each developer tool is outside the scope of this book, but it’s worth briefly review-ing what’s available. For more detail than is included here, check out the Android documentation at:

http://code.google.com/android/intro/tools.html

As mentioned earlier, the ADT plug-in conveniently incorporates most of these tools into the Eclipse IDE, where you can access them from the DDMS perspective, including:

❑The Android Emulator An implementation of the Android virtual machine designed to run on your development computer. You can use the emulator to test and debug your android applications.

❑Dalvik Debug Monitoring Service (DDMS) Use the DDMS perspective to monitor and con-trol the Dalvik virtual machines on which you’re debugging your applications.

❑Android Asset Packaging Tool (AAPT) Constructs the distributable Android package files (.apk).

❑Android Debug Bridge (ADB) The ADB is a client-server application that provides a link to a running emulator. It lets you copy files, install compiled application packages (.apk), and run shell commands.

The following additional tools are also available:

❑SQLite3 A database tool that you can use to access the SQLite database files created and used by Android

❑Traceview Graphical analysis tool for viewing the trace logs from your Android application

❑MkSDCard Creates an SDCard disk image that can be used by the emulator to simulate an external storage card.

❑dx Converts Java .class bytecode into Android .dex bytecode.

❑activityCreator Script that builds Ant build files that you can then use to compile your Android applications without the ADT plug-in

Let’s take a look at some of the more important tools in more detail.

The Android Emulator

The emulator is the perfect tool for testing and debugging your applications, particularly if you don’t have a real device (or don’t want to risk it) for experimentation.

The emulator is an implementation of the Dalvik virtual machine, making it as valid a platform for run-ning Android applications as any Android phone. Because it’s decoupled from any particular hardware, it’s an excellent baseline to use for testing your applications.

A number of alternative user interfaces are available to represent different hardware configurations, each with different screen sizes, resolutions, orientations, and hardware features to simulate a variety of mobile device types.

Full network connectivity is provided along with the ability to tweak the Internet connection speed and latency while debugging your applications. You can also simulate placing and receiving voice calls and SMS messages.

The ADT plug-in integrates the emulator into Eclipse so that it’s launched automatically when you run or debug your projects. If you aren’t using the plug-in or want to use the emulator outside of Eclipse, you can telnet into the emulator and control it from its console. For more details on controlling the emu-lator, check the documentation at http://code.google.com/android/reference/emulator.html.

At this stage, the emulator doesn’t implement all the mobile hardware features supported by Android, including the camera, vibration, LEDs, actual phone calls, the accelerometer, USB connections, Bluetooth, audio capture, battery charge level, and SD card insertion/ejection.

Dalvik Debug Monitor Service (DDMS)

The emulator lets you see how your application will look, behave, and interact, but to really see what’s happening under the surface, you need the DDMS. The Dalvik Debug Monitoring Service is a power-ful debugging tool that lets you interrogate active processes, view the stack and heap, watch and pause active threads, and explore the filesystem of any active emulator.

The DDMS perspective in Eclipse also provides simplified access to screen captures of the emulator and the logs generated by LogCat.

If you’re using the ADT plug-in, the DDMS is fully integrated into Eclipse and is available from the DDMS perspective. If you aren’t using the plug-in or Eclipse, you can run DDMS from the command line, and it will automatically connect to any emulator that’s running.

The Android Debug Bridge (ADB)

The Android debug bridge (ADB) is a client-service application that lets you connect with an Android Emulator or device. It’s made up of three components: a daemon running on the emulator, a service that runs on your development hardware, and client applications (like the DDMS) that communicate with the daemon through the service.

As a communications conduit between your development hardware and the Android device/emulator, the ADB lets you install applications, push and pull files, and run shell commands on the target device. Using the device shell, you can change logging settings, and query or modify SQLite databases avail-able on the device.

The ADT tool automates and simplifies a lot of the usual interaction with the ADB, including applica-tion installation and update, log files, and file transfer (through the DDMS perspective).

To learn more about what you can do with the ADB, check out the documentation at http://code.google.com/android/reference/adb.html.

Summary

This chapter showed you how to download and install the Android SDK; create a development envi-ronment using Eclipse on Windows, Mac OS, or Linux platforms; and how to create run and debug con-figurations for your projects. You learned how to install and use the ADT plug-in to simplify creating new projects and streamline your development cycle.

You were introduced to some of the design considerations for developing mobile applications, particu-larly the importance of optimizing for speed and efficiency when increasing battery life and shrinking sizes are higher priorities than increasing processor power.

As with any mobile development, there are considerations when designing for small screens and mobile data connections that can be slow, costly, and unreliable.

After creating an Android to-do list application, you were introduced to the Android Emulator and the developer tools you’ll use to test and debug your applications.

Specifically in this chapter, you:

❑Downloaded and installed the Android SDK.

❑ Set up a development environment in Eclipse and downloaded and installed the ADT plug-in. ❑ Created your first application and learned how it works.

❑ Set up run and debug launch configurations for your projects. ❑ Learned about the different types of Android applications.

❑Were introduced to some mobile-device design considerations and learned some specific Android design practices.

❑Created a to-do list application.

❑Were introduced to the Android Emulator and the developer tools.

The next chapter focuses on Activities and application design. You’ll see how to define application set-tings using the Android manifest and how to externalize your UI layouts and application resources. You’ll also find out more about the Android application life cycle and Android application states.