Introduction to Android SDK Development

Today we'll be taking a look at Android development: explaining why people have chosen to work with Android and providing an overview of the Eclipse IDE and its Java, DDMS (MySQL) and debugging perspectives. Finally, you'll learn how to get started making your first Android app!
Android is an open source mobile operating system that combines and builds upon parts of many different open source projects. What does this mean to you as a developer? You have access to the source code of the platform that is running on the phone. This can help you better understand how interface controls and the various other pieces work. If you happen to find a bug, you can also submit a patch for the issue, though this is a more advanced practice. Google has also pulled together a large group of companies (called the Open Handset Alliance) that both contribute to and use the Android OS in their hardware devices. This means that there is industry-wide support for Google's OS, promising wide adoption across well-known vendors.
There are many advantages to developing for the Android platform:
  • Zero startup costs to begin development. The development tools for the platform are free to download, and Google only charges a small fee to distribute applications on the Android Market.
  • Freedom to innovate. The Android OS is an open-source platform based on the Linux kernel and multiple open-source libraries. In addition to building applications to run on Android devices, developers are free to contribute to or extend the platform as well.
  • Freedom to collaborate. Android developers are not required to sign an NDA and are encouraged to collaborate and share source code with each other. According to a survey by Black Duck Software, the number of open source mobile apps and libraries grew at a rate of 168% from 2008 to 2009, faster on Android than any other platform. This means more code that you can reuse in your own projects to bring them to market much faster.
  • Open distribution model. Very few restrictions are placed on the content or functionality allowed in Google’s Android Market, and developers are free to distribute their applications through other distribution channels as well.
  • Multi-platform support. There are a wide variety of hardware devices powered by the Android OS, including many different phones and tablet computers. Development for the platform can occur on Windows, Mac OS or Linux.
  • Multi-carrier support. A large number of telecom carriers currently offer Android powered phones.
Prerequisites before continuing with this article include:
Eclipse is a complex, multi-language, and extensible Integrated Development Environment (IDE). The learning curve can be steep, but the power of the environment can greatly increase your efficiency.
After opening Eclipse for the first time, select a workspace to save your project within. You will see an introduction screen with multiple icons. Select the “go to workbench” option, and you will be presented with the default project screen.
Assuming you have already installed the Eclipse ADT plugin, you will need to configure Eclipse for Android development by manually setting the filepath for the Android SDK. To do this, select Eclipse > Preferences from the main tool bar, and then select Android from the dialogue box that appears. Update the “SDK Location” option to point to the directory where you installed the SDK. You should now have the IDE configured for Android development.
It is important to note that Eclipse uses something called “perspectives” to group commonly used tasks. Switching perspectives will switch out parts of the menu and toolbars, and will show and hide views related to them. Perspectives can be opened by clicking on the Open Perspective button or by choosing Window > Open Perspective. Some perspectives that you will use frequently include Java, Debugging and DDMS.
The Java perspective is the default perspective in Eclipse, and it is where you will probably spend most of your time.

Among the most important views in this perspective is the Package Explorer view, by default located on the left hand column of the workbench. This view is an overview of your entire project. It also shows the states of individual files with regard to compile issues, version control, etc.
Another important view in the Java perspective is the Problems view, by default located in the bottom center panel of the workbench. This is where you will find compile warnings and errors listed. You can double-click an item to be taken directly to the error in the Java or XML file.
DDMS is short for Dalvik Debug Monitor Server, which communicates with the low-level services of a device or emulator. Switch to the DDMS perspective now by selecting Window > Open Perspective > DDMS.


The Devices view, located in the left column of the workbench, is where you will see any Android devices available to your computer. This includes both phones attached to your machine and running emulators. Under each device, you will see all the running processes. There are toolbar buttons on the view for launching the debugger on a process, getting information about heaps and threads, stopping processes, and taking screenshots.
The Emulator Control view, also in the left column, lets you do the following:
  • Set the status of the voice connection.
  • Set the status, speed and latency of the data connection.
  • Simulate an incoming call or SMS from a supplied phone number.
  • Provide a simulated set of points for the GPS via a latitude/longitude point, or GPX/KML file.
  • Using the File Explorer view, accessible as a tab at the top-right of the center column, you can browse the file system of a device. For an emulator or a rooted phone, you will have access to the private directories /data and /system. For non-rooted phones, you will only have access to /sdcard.
    The debugging perspective will provide in-depth information about your applications. Switch to the debugging perspective now by selecting Window > Open Perspective > Debug.
    The Debug view will show you the running apps being analyzed, and, when stopped on a breakpoint or exception, the call stack of the application as well. The Variables view displays the contents of any local variables at the current breakpoint.
    The LogCat view in the lower right hand corner displays all logging output using the android.util.Log class. You can filter based on tags, or different log levels such as debug, information, error, etc.
    Building of First Application is coming in Next Post-> My First Application.

Comments

Popular Posts