Getting Started with Android
11:35 AM // 0 comments // Sajib Barua // Category: Android Applications //previous The Dalvik Virtual Machine
http://code.google.com/android/download.html
All you need to start writing your own Android applications is a copy of the Android SDK and the Java development kit. Unless you’re a masochist, you’ll probably want a Java IDE — Eclipse is particularly well supported — to make development a little easier.
Versions of the SDK, Java, and Eclipse are available for Windows, Mac OS, and Linux, so you can explore Android from the comfort of whatever OS you favor. The SDK includes an emulator for all three OS environments, and because Android applications are run on a virtual machine, there’s no advantage to developing from any particular operating system.
Android code is written using Java syntax, and the core Android libraries include most of the features from the core Java APIs. Before they can be run, though, your projects are first translated into Dalvik byte code. As a result, you get the benefits of using Java, while your applications have the advantage of running on a virtual machine optimized for Android devices.
The SDK download includes all the Android libraries, full documentation, and excellent sample applications. It also includes tools to help you write and debug your applications, like the Android Emulator to run your projects and the Dalvik Debug Monitoring Service (DDMS) to help debug them.
By the end of this chapter, you’ll have downloaded the Android SDK, set up your development environment, completed two new applications, and run and debugged them using the emulator and DDMS.
If you’ve developed for mobile devices before, you already know that their small-form factor, limited power, and restricted memory create some unique design challenges. Even if you’re new to the game, it’s obvious that some of the things you can take for granted on the desktop or the Web aren’t going to work on a mobile.
As well as the hardware limitations, the user environment brings its own challenges. Mobile devices are used on the move and are often a distraction rather than the focus of attention, so your applications need to be fast, responsive, and easy to use.
Developing for Android
The Android SDK includes all the tools and APIs you need to write compelling and powerful mobile applications. The biggest challenge with Android, as with any new development toolkit, is learning the features and limitations of its APIs.
If you have experience in Java development, you’ll find that the techniques, syntax, and grammar you’ve been using will translate directly into Android, although some of the specific optimization techniques may seem counterintuitive.
If you don’t have experience with Java but have used other object-oriented languages (such as C#), you should find the transition straightforward. The power of Android comes from its APIs, not from Java, so being unfamiliar with all the Java specific classes won’t be a big disadvantage.
What You Need to Begin
Because Android applications run within the Dalvik virtual machine, you can write them on any platform that supports the developer tools. This currently includes the following:
- Microsoft Windows (XP or Vista)
- Mac OS X 10.4.8 or later (Intel chips only)
- Linux
To get started, you’ll need to download and install the following:
- The Android SDK
- Java Development Kit (JDK) 5 or 6
You can download the latest JDK from Sun at
http://java.sun.com/javase/downloads/index.jsp
If you already have a JDK installed, make sure that it meets the version requirements listed above, and note that the Java runtime environment (JRE) is not sufficient.
Downloading and Installing the SDK
The Android SDK is completely open. There’s no cost to download and use the API, and Google doesn’t charge to allow distribution of your finished programs. You can download the latest version of the SDK for your development platform from the Android development home page athttp://code.google.com/android/download.html
Unless otherwise noted, the version of the Android SDK used for writing this book was version 1.0 r1.
The SDK is presented as a ZIP fi le containing the API libraries, developer tools, documentation, and several sample applications and API demos that highlight the use of particular API features. Install it by unzipping the SDK into a new folder. (Take note of this location, as you’ll need it later.)
The examples and step-by-step instructions provided are targeted at developers using Eclipse with the Android Developer Tool (ADT) plug-in. Neither is required, though — you can use any text editor or Java IDE you’re comfortable with and use the developer tools in the SDK to compile, test, and debug the code snippets and sample applications.
The examples included in the SDK are well documented and are an excellent source for full, working examples of applications written for Android. Once you’ve finished setting up your development environment, it’s worth going through them.
Developing with Eclipse
Using Eclipse with the ADT plug-in for your Android development offers some significant advantages.
Eclipse is an open source IDE (integrated development environment) particularly popular for Java development. It’s available to download for each of the development platforms supported by Android (Windows, Mac OS, and Linux) from the Eclipse foundation homepage:
www.eclipse.org/downloads/
There are many variations available when selecting your Eclipse download; the following is the recommended configuration for Android:
- Eclipse 3.3, 3.4 (Ganymede)
- Eclipse JDT plug-in
- WST
-
WST and the JDT plug-in are included in most Eclipse IDE packages.
Installing Eclipse consists of uncompressing the download into a new folder. When that’s done, run the Eclipse executable. When it starts for the first time, create a new workspace for your Android development.
Using the Eclipse Plug-in
The ADT plug-in for Eclipse simplifies your Android development by integrating the developer tools, including the emulator and .class-to-.dex converter, directly into the IDE. While you don’t have to use the ADT plug-in, it does make creating, testing, and debugging your applications faster and easier.
The ADT plug-in integrates the following into Eclipse:
- An Android Project Wizard that simplifies creating new projects and includes a basic application template
- Forms-based manifest, layout, and resource editors to help create, edit, and validate your XML resources
- Automated building of Android projects, conversion to Android executables (.dex), packaging to package fi les (.apk), and installation of packages onto Dalvik virtual machines
- The Android Emulator, including control of the emulator’s appearance, network connection settings, and the ability to simulate incoming calls and SMS messages
- The Dalvik Debug Monitoring Service (DDMS), which includes port forwarding; stack, heap, and thread viewing; process details; and screen capture facilities
- Access to the device or emulator’s filesystem, allowing you to navigate the folder tree and transfer files
- Runtime debugging, so you can set breakpoints and view call stacks
- All Android/Dalvik log and console outputs
Figure 2-1 shows the DDMS perspective within Eclipse with the ADT plug-in installed.
Installing the ADT Plug-in
Install the developer tools plug-in by the following steps:
- Select Help ➪ Software Updates ➪ Find and Install … from within Eclipse.
- In the resulting dialog box, choose Search for new features to install.
- Select New Remote Site, and enter the following address into the dialog box, as shown in Figure 2-2: https://dl-ssl.google.com/android/eclipse/
- The new site you entered should now be checked. Click Finish.
- Eclipse will now download the plug-in. When it’s fi nished, select Android Plugin ➪ Developer Tools from the resulting Search Results dialog box, and click Next.
- Read and then Accept the terms of the license agreement, and click Next and then Finish. As the ADT plug-in is not signed, you’ll be prompted before the installation continues.
- When complete, you’ll have to restart Eclipse and update the ADT preferences. Restart and select Window ➪ Preferences … (or Eclipse ➪ Preferences for the Mac OS).
- Then select Android from the left panel.
- Click Browse …, and navigate to the folder into which you unzipped the Android SDK, as shown in Figure 2-3; then click Apply and OK.
If you download a new version of the SDK and place it in a different location, you will need to update this preference to reflect the SDK with which the ADT should be building.
Updating the Plug-inAs the Android SDK matures, there are likely to be frequent updates to the ADT plug-in. In most cases, to update your plug-in, you simply:
- Navigate to Help ➪ Software Updates ➪ Find and Install …
- Select Search for updates of the currently installed features, and click Finish …
- If there are any ADT updates available, they will be presented. Simply select them and choose Install.
Sometimes a plug-in upgrade is so significant that the dynamic update mechanism can’t be used. In those cases, you may have to remove the previous plug-in completely before installing the newer version as described in the previous section.
next Creating Your First Android Activity
Related posts :
0 comments for this post
Leave a reply
Microsoft Word LaTeX Shortcut...
05-Nov-2020Learn Python...
23-Mar-2019A Mathematical Theory of Comm...
10-Dec-2015The Free Energy Secrets of Co...
26-Dec-2014Electronic refrigeration usin...
23-Nov-2014
- Radhika says:
Nice. Thanks for the great information. I have read many blogs but this blog is really informative....[[More detail]] - arohi patil says:
Two Stage Transformer Oil Filtration Plant - Jhun05 says:
Hi, i really needineed help,isais there anyone who can help me about this kV2c FM45s GE electric...[[More detail]] - arif says:
You possess lifted an essential offspring..Blesss for using..I would want to study better latest...[[More detail]] - Dilip says:
Very informative blog. thank you for sharing . keep posting.[[More detail]]