Mobile application development, Part 1
- Mobile Application Development Platform
- Mobile Application Development Company
- Free Download Mobile Application
- Download Eclipse For Mobile Application Development System
- Ide For Mobile Application Development
Content series:
An IDE for developers creating Android applications. Skip to main content. Eclipse Packages. Members; Working Groups. Eclipse Java Development Tools; Maven Integration for Eclipse. All downloads are provided under the terms and conditions of the Eclipse Foundation Software User Agreement unless otherwise specified. For example in C:eclipse on windows, or /usr/local/eclipse on Linux and finally set PATH variable appropriately. Eclipse can be started by executing the following commands on windows machine, or you can simply double click on eclipse.exe%C:eclipseeclipse.exe Eclipse can be started by executing the following commands on Linux machine −. Aug 17, 2011 Android Application Development Tutorial - 1 - Download and Install the Java JDK. Android Application Development Tutorial - 2 - Installing Eclipse and Setting up the. Android Application.
Know the components and structure of mobile application development frameworks for Android and windows OS based mobiles. Understand how to work with various mobile application development frameworks. Learn the basic and important design concepts and issues of development of mobile applications. How to install Eclipse For Android development. Android applications, like most mobile phone applications, are developed in a host-target development environment. In other words, you develop your application on a host computer (where resources are abundant), and download it to a target mobile phone for testing and ultimate use. Mobile Tools for Java™ project creates tools and frameworks to extend Eclipse platform to support embedded and mobile device Java application development. Scope The scope of the Mobile Tools for the Java™ (MTJ) project is to extend the Eclipse platform to enable developers to develop, debug, and deploy embedded and mobile Java applications.
This content is part # of # in the series: Mobile application development, Part 1
http://www.ibm.com/developerworks/web/library/?series_title_by=mobile+application+development
This content is part of the series:Mobile application development, Part 1
Stay tuned for additional content in this series.
Everywhere you go, people are using mobile devices to keep in touch with family and friends, take a picture to post on a social website, find the location of a restaurant, or check the latest news headlines. Mobile devices come in many different shapes and styles. Mobile phones run a variety of different operating systems such as Apple's iOS, Google's Android, and Research In Motion's Blackberry. Some have large displays, physical keyboards, and run on 3G, 4G, or WiFi networks. Mobile phones may also have sensors for acceleration, location, or even payments. Some of these devices aren't even phones; they're tablets with larger displays and a a web application, the user enters a URL into the mobile web browser. This loads the web page, which is the entry point into a web application. Web applications are not distributed through an app store; they are simply links that can be included in other web pages, e-mails, or even hard copy.
Native and web applications both have advantages and disadvantages, and many arguments have been waged over which is better. In an effort to resolve this battle, a new hybrid application tries to combine the advantages from both native and web applications.
Hybrid applications are programmed using web technologies, like web applications, but are packaged as a native application. A hybrid application can be written once for multiple device operating systems using a programming language familiar to many developers. Since a hybrid application is really a native application, you have access to device features from JavaScript that are not currently available to web applications. Hybrid applications can also be distributed and installed using app stores, just like a native application.
PhoneGap is a popular toolkit for building hybrid applications. It's an open source mobile framework that includes a JavaScript API for access to device features, such as the accelerometer and camera.
This article shows you how to develop a hybrid mobile Android application using the PhoneGap and Dojo Mobile toolkits. Learn how to use the Android emulator and tools for testing applications, and see how to run your application on an Android device or tablet.
Prerequisites
This article assumes you have some familiarity with the Eclipse development environment, HTML, JavaScript, and CSS. The following software is required:
- Windows, OSX, or Linux operating system
- Java Development Kit (JDK) 5 or JDK 6 (a JRE is not sufficient)
- An Eclipse development environment, such as Eclipse Helios V3.6 or later, or IBM Rational Application Developer V8
- Android SDK and platforms (r12 or later)
- Android Development Toolkit (ADT) plugin for Eclipse
- PhoneGap SDK (V1.0.0 or later)
- Dojo Toolkit (V1.6 or later)
See Related topics for links to download the software.
Set up your development environment
To set up the development environment, you need to perform the following steps:
- Install the JDK and Eclipse or Rational Application Developer.
- Download the Android SDK.
- Download and install the ADT plugin for Eclipse.
- Configure Eclipse for Android.
- Install the required Android platforms.
- Create a new Android Virtual Device (AVD).
- Download the PhoneGap SDK.
- Download the Dojo Toolkit.
Install the JDK and Eclipse or Rational Application Developer
The first task is to verify that JDK 5 or greater is installed. If not, download Java SE JDK (see Related topics).
You can use either Eclipse or IBM Rational Application Developer (RAD) for this article. Windows or Linux is supported by RAD. OSX developers can use Eclipse.
RAD consists of IBM's version of Eclipse with additional IBM tools to support Java EE, including IBM's Web 2.0 Feature Pack. To use RAD, you will need Version 8 or later. RAD includes IBM's JDK, which is used by default. However, this JDK does not contain the Java packages needed to create and sign an Android application. To use the Java SE JDK instead, you need to replace C:/Program Files/IBM/SDP/eclipse.ini (or the location you installed RAD) with the information in Listing 1.
Listing 1. Content of eclipse.ini for RAD on Windows
If you want to use Eclipse, you will need Version 3.6 or later. Since you'll be writing web services later in this series, download the Eclipse IDE for Java EE Developers (see Related topics). However, if you only want to write an Android application, you can get by with using the Eclipse IDE for Java Developers.
Eclipse and RAD are very similar. In this article, when Eclipse is mentioned it implies either Eclipse or RAD. However, figures of screens are from RAD running on Windows.
Download the Android SDK
The Android SDK (see Related topics) must be used to make Android applications. It is a collection of command line programs that are used to compile, build, emulate, and debug Android applications.
If you are installing on Windows, it's easiest to download the zip package and extract it into your C: root directory. There are a couple of issues with the r12 installer not being able to detect Java or install into a directory with spaces in it's name.
Download and install the ADT plugin
Android provides an Eclipse plugin that greatly simplifies application development. It integrates with Eclipse to provide a rapid development environment. To install the Android Development Toolkit (ADT) plugin (see Related topics), follow the steps below:
- From Eclipse, select the menu items Help > Install New Software… > Add…
- Enter the name and URL location of the software, as shown in Figure 1. Name: Android ADT Eclipse plugin; location: https://dl-ssl.google.com/android/eclipse/.
Figure 1. Installing Android ADT plugin
- Select Developer Tools, verify that all check boxes are selected, as shown in Figure 1, and then select Next.
- As shown in Figure 2, select Next to accept license agreements and install the items.
Figure 2. Install details
After installation is complete, restart Eclipse.
Configure Eclipse for Android
To configure Eclipse for Android, display the Preferences dialog.
- For Windows, select Window > Preferences > Android.
- For OSX, select Eclipse > Preferences > Android.
For the SDK location, select Browse…, and then choose the directory where the Android SDK is located, as shown in Figure 3:
Figure 3. Specify SDK location to Eclipse
Select Apply and OK.
Add the Android LogCat view to the Eclipse IDE to aid with debugging:
- Window > Show View > Other…
- Android > LogCat
Figure 4. LogCat view
Install an Android platform
To compile an Android application for a particular version, one or more Android platforms must be downloaded and installed. The platforms include the library files and emulators.
From Eclipse, open the Android SDK and AVD Manager, which is used to manage the Android SDK versions and emulators used with your applications.
Select Window > Android SDK and AVD Manager, as shown in Figure 5:
Figure 5. Menu item for Android configuration
Install the SDK platforms required for the versions of Android on which you wish to run your applications.
Mobile Application Development Platform
The example application will be using GPS location services, so you should select and install a platform based upon the Google APIs. For example, select Google APIs by Google Inc., Android API 8, revision 2, as shown in Figure 6. If you are not using GPS, then you can install platforms listed under the Android Repository category.
For Windows installations, select the Google USB Driver package to provide support for connecting your Android phone.
Select Install Selected.
Figure 6. Android SDK and AVD Manager
Accept the licence agreement for each package, and then select Install, as shown in Figure 7:
Figure 7. Android packages to install
The manager will download and install the selected packages.
Create a virtual Android device
The Android SDK and AVD Manager are also used to create and manage the emulator instances to be used with your applications.
From the Virtual Devices page, select New… to create a new AVD. As shown in Figure 8, enter a name, target, SD card size, and HVGA skin:
Figure 8. Creating a new AVD
Select Create AVD.
Download PhoneGap SDK
PhoneGap is an open source hybrid mobile application framework that supports multiple platforms, including Android, iOS, Blackberry, Palm, Symbian, and Windows Phone. With PhoneGap you can easily write a cross-platform mobile application using standard web technologies (HTML, JavaScript, and CSS) and access device features such as the accelerometer or camera from JavaScript. See Related topics for a link to information for the supported features, which provides the latest details about PhoneGap.
PhoneGap provides a collection of JavaScript APIs that enables access to many device features not available from the mobile web browser for a typical web application. This is accomplished by using a native wrapper around your web application. PhoneGap combines web application code with the device's browser renderer to produce a native application that can be deployed to an app store and installed on the device.
Features included as part of the PhoneGap API enable access to a device's accelerometer, audio and video capture, camera, compass, contacts, file, geolocation, network, notification, and storage. The PhoneGap API documentation (see Related topics) has more details and examples.
After you download PhoneGap (see Related topics), you'll later copy the code into your Android project (in the 'Create a new Android project' section).
Download Dojo
Dojo Toolkit is an open source JavaScript toolkit designed for rapid development of websites and applications that are loaded and run in a web browser.
Since mobile web browsers are not as capable as desktop browsers, Dojo includes a mobile version, called Dojo Mobile. It is optimized for mobile web browsers, and it provides many UI widgets and themes you can use to style your mobile application to mimic a native application.
Some key features of Dojo Mobile include:
- Lightweight loading of widgets due to the Dojo Mobile parser
- CSS3 animations and transitions for native-like application experience on high-end iOS and Android devices
- Themes included for both iOS and Android look and feel
- Compatibility with non-CSS3-compatible devices and browsers
- Full declarative syntax, allowing for an easy learning curve
- A large suite of widgets, with even more in the upcoming Dojo Mobile 1.7
For this article, you will need to download Dojo 1.6 (see Related topics).
Create a new Android project
Now that the development environment is set up, let's start by creating a simple Android application.
From Eclipse, select File > New > Other…, then Android > Android project. You should see the dialog shown in Figure 9.
Figure 9. New Android project
As shown in Figure 9, enter a project name, select a build target, and enter the application name, package name, and activity name. Click on Finish to create the project.
Add the PhoneGap library
You now have a simple Android application. Before you can write a PhoneGap application, you need to add the PhoneGap library. There are two files: a JavaScript file that contains the PhoneGap API called by our application, and a native JAR file containing the native implementation for the PhoneGap API.
- Expand the AndroidPhoneGap project tree view, as shown in Figure 10:
Figure 10. Android project with PhoneGap library
- Create the directory assetswww. Also create the directory libs if it doesn't already exist.
- Unzip the PhoneGap download and locate the Android subdirectory.
- Copy the three PhoneGap library files for Android to the following Eclipse project folders:
- Copy phonegap-1.0.0.jar to libsphonegap-1.0.0.jar
- Copy phonegap-1.0.0.js to assetswwwphonegap-1.0.0.js
- Copy xml/plugins.xml to resxmlplugins.xml
Even though the PhoneGap JAR file is copied into the project, you also need to add it to the project's build path.
- Select Project > Properties > Java Build Path > Libraries > Add JARs….
- Add phonegap-1.0.0.jar by navigating to it in the project, as shown in Figure 11:
Figure 11. Adding PhoneGap JAR
The final step in preparing the example Android application to use PhoneGap is to modify App.java. Because a PhoneGap application is written in HTML and JavaScript, you need to change App.java to load your HTML file using
loadUrl()
, as shown in Listing 2. You can edit App.java by double-clicking on App.java in the tree view shown in Figure 10.Listing 2. App.java
Write the PhoneGap application
You're now ready to start writing the PhoneGap application. For Android, files under the asset directory are referenced using file:///android_asset. As specified in
loadUrl()
in Listing 2, you need to create an index.html file under assets/www. After creating index.hml, enter the contents of Listing 3 below.
Listing 3. index.html
A brief explanation of index.html is in order. Before calling any PhoneGap APIs, we must wait for the
deviceready
event, which indicates that the native portion of PhoneGap has been initialized and is ready. In Listing 3, the onload
callback registers for deviceready
. When it fires, we write out the device's OS and version. Since PhoneGap uses native features that are protected by permissions, you need to modify AndroidManifest.xml to include these
uses-permission
tags. You also need to specify the support-screens
tag, the android:configChanges
property, and the com.phonegap.DroidGap
activity tag, as shown in Listing 4:Listing 4. AndroidManifest.xml
Run the application in the Android emulator
The PhoneGap application is now ready to run. Select Run > Run As > Android Application, and you should see something similar to Figure 12
Figure 12. Android emulator
Eclipse automatically builds the application, launches the emulator, and installs and runs it on the emulator.
The emulator can take several minutes to start up. To speed development, keep the emulator running until you are done with your development session. Eclipse will automatically use a running emulator instead of launching a new one.
Download this app from Microsoft Store for Windows 10, Windows 10 Mobile, Windows 10 Team (Surface Hub), HoloLens. See screenshots, read the latest customer reviews, and compare ratings for Windows File Manager. Download file manager for windows phone 7.8 ndows phone 7 8 to 8 0. Download File Manager for Windows Phone. DriveHQ is the first Cloud IT Solution provider. We offer remote file server, FTP server, email server and web server hosting services, as well as many other advanced features such as: remote sharing and collaboration, automatic online backup, drop box, f. Jul 29, 2019 Here is an official Mi Phone manager 2019 supports Windows XP/7/8/10 Operating system. To start with, download Mi pc suite files from above download links and then run the setup. Follow the instructions running on the screen, and you all have done. Once a successful installation, you may notice a Shortcut icon of Mi PC Suite in your Desktop. Jan 22, 2013 Microsoft Download Manager is free and available for download now. The Windows Phone SDK Update for Windows Phone 7.8 adds two new emulator images to your existing Windows Phone SDK installation. This update supports both the Windows Phone SDK 7.1 and the Windows Phone SDK 8.0. Jul 07, 2018 Download X-plore File Manager for PC (Windows 7, 8, 10 & Mac) 3 (60%) 16 votes The different versions of X-plore have come as good news for different phone loves and computer users.
Run the application on an Android phone
If you have an Android phone, you can run the PhoneGap application on your device. However, before you can use your phone for development, you need to turn on USB debugging, as follows:
- Go to the Home screen and select Menu.
- Select Settings > Applications > Development.
- Enable USB debugging.
- You also need to declare the application as debuggable in the Android Manifest. Edit the AndroidManifest.xml file to add
android:debuggable='true'
to the<application>
element. - Attach an Android phone to your development machine with USB.
- To run the application, select Run As > Android Application. You will be prompted to choose between the emulator or real device as the target. Select the Android phone, as shown in Figure 13:
Figure 13. Select the device
Once the application has been downloaded and installed on your phone, it will be launched, as shown in Figure 14:
Figure 14. Application running on device
Use the Dalvik Debug Monitor Server (DDMS)
The ADT plugin includes a Dalvik Debug Monitor Server (DDMS) perspective for debugging. DDMS, which can be used to track and debug the application flow, can be used with the emulator or a real device.
The DDMS perspective can be started from Eclipse by selecting Window > Open Perspective > Other.. > DDMS. Figure 15 shows an example.
Figure 15. DDMS window inside Eclipse
The DDMS can also be started using command line from the location of the Android SDK.
- For Windows: C:android-sdk-windowstoolsddms.bat
- For OSX: ../android-sdk-mac-86/tools/ddms
Figure 16. Standalone debugger
From DDMS, you can:
- View the log console
- Show the status of processes on the device
- Examine thread information
- View heap usage of a process
- Force garbage collection
- Track memory allocation of objects
- Perform method profiling
- Work with a device's file system
- Perform screen captures of the device
- Emulate phone operations
See the DDMS documentation (in Resource) for more information.
Extend the project with Dojo
Dojo is a JavaScript toolkit that offers several benefits to mobile applications. It provides themes that mimic native mobile applications, and it has user interface (UI) containers and widgets that simplify development of your application UI.
Setup for Dojo
To use Dojo, you need to copy it into the example project.
Create the following directories, as shown in Figure 17.
- assetswwwlibs
- assetswwwlibsdojo
- assetswwwlibsdojodojo
- assetswwwlibsdojodojox
Copy the following Dojo files:
- dojoxmobile.js to assetswwwlibsdojodojox directory
- dojoxmobile directory to assetswwwlibsdojodojox directory
- dojodojo.js to assetswwwlibsdojodojo directory
Figure 17. Android project tree with Dojo added
To load Dojo, you need to edit index.html and include the lines in Listing 5 in the
<head>
section before the phonegap-1.0.0.js script tag.Listing 5. Adding Dojo to index.html
After the phonegap-1.0.0.js script tag, include the
require
statements, as shown in Listing 6, for the Dojo mobile parser.Listing 6. Modify index.html to load mobile Dojo
Updating the application
Replace the existing
<body>
tag in index.html with a new <body>
tag that contains two simple <div> sections, as shown in Listing 7:Listing 7. Modify body of index.html
As shown in Listing 8, add a simple JavaScript function,
itemClicked()
after the last <div>
tag to log to the console. Listing 8. Onclick handler
Running on an emulator
Run the application as an Android application by right-clicking on the project and selecting Run as > Android Application.
Figure 18. Application running on emulator
Each screen in a Dojo application is defined by a
div
element with dojoType='dojox.mobile.View'
, as shown in Listing 9. The initial screen is identified with the attribute selected='true'
. The title of the screen is defined by a
<h1 dojoType='dojox.mobile.Heading'>
tag.Listing 9. Defining screen and title
Notice the
>
on the last three list items. It is an indicator that another Dojo screen will be loaded. A list item tag with
dojoType='dojox.mobile.ListItem'
is used to display a list of items that can be selected, as shown in Listing 10. It is rendered as a native selection list. The moveTo
attribute specifies which div
to display, and the transition
attribute specifies how it is to be moved into view.Listing 10. List item to load a new screen
Select Exchange Driver Info, which will hide the current
div
and show the target div with id='accInfo'
. You should see the Driver screen slide into view, as shown in Figure 19Figure 19. Driver information screen
The list items can be used for more than loading other screens. For example, the
onclick
handler can be used to display a Google map with a search for the nearest police station. Listing 11 shows the code. To return back to the previous screen, select the Accident button in the title.
Listing 11. List item to load a Google map
Many mobile devices support the geo: protocol. By loading a URI of the form
geo:lat,lng?q=query
, the native Google map service will be displayed.Select Call the Police on the emulator, which will display a map of the nearest police station, as shown in Figure 20:
Figure 20. Search for nearest police station
Your location may be different, depending on the latitude and longitude entered under the Emulator Control in DDMS. Figure 21 shows the location settings.
Figure 21. Location settings in DDMS
Run on a device
If you have an Android phone connected, run the application on your device as described in the 'Run the application on an Android phone' section. As shown in Figure 22, the screens will look similar to those on the emulator. The police search should return a police station near your current location.
Figure 22. Application running on device
Mobile Application Development Company
Conclusion
In this article, you learned how to combine PhoneGap and Mobile Dojo to rapidly create a hybrid mobile application for Android that looks and behaves like a typical Android application. You could write it quickly because we used HTML and JavaScript instead of Java. Given that the web code remains the same across all mobile operating systems, this hybrid application could be easily built for iOS and Blackberry with minimal effort.
Stay tuned for Part 2 in this series, which will cover writing a mobile insurance application using Dojo and PhoneGap.
Downloadable resources
Related topics
- Download Eclipse.
- Get Dojo 1.6.
- Download IBM Rational Application Developer 8.0.3 (Trial version).
- Download Java SE JDK.
- Get the Android SDK download and installation guide.
- Download the ADT Plugin for Eclipse and installation guide.
- Try out IBM software for free. Download a trial version, log into an online trial, work with a product in a sandbox environment, or access it through the cloud. Choose from over 100 IBM product trials.
- Using DDMS for Android debugging explains how DDMS interacts with a debugger.
- Get DDMS documentation on the Android developer's site.
- Explore the PhoneGap:
- The PhoneGap Get Started Guide covers installation, setup, and deployment.
- Learn about the Mobile Dojo features.
- Access all the Dojo documentation.
- 'Get started with Dojo Mobile 1.6' (developerWorks, Jun 2011) shows how to include and use Dojo Mobile widgets and components in your applications. Also learn how to wrap your web application in a native application using PhoneGap.
Comments
Sign in or register to add and subscribe to comments.
Lesson 7: Develop Apps with Eclipse
Although it’s not too demanding to develop simple Android apps (e.g., Lesson 3’s W2A app) at the command line, you will probably find it tedious to develop more complex apps in this environment. For this reason, you might prefer to use the Eclipse Integrated Development Environment (IDE).
Lesson 7 completes this course by teaching you how to use Eclipse to develop W2A. Free download fishing games for phone. First, you learn how to install this IDE, and then learn how to install the ADT Plugin, which simplifies Android app development and testing. You can then learn how to create and run W2A in this environment.
Installing Eclipse
According to Google’s system requirements, you must install an Eclipse 3.6 (Helios) or greater package that includes the Java Development Tools (JDT) plugin. Google recommends that you install one of the following packages:
- Eclipse IDE for Java Developers
- Eclipse Classic
- Eclipse IDE for Java EE Developers
The eclipse.org website makes several IDE packages that meet different requirements available for download. I chose to download Eclipse Classic 3.7.1 for the Windows XP platform.
Assuming that you are also running Windows, point your browser to the Eclipse Classic 3.7.1 web page (http://www.eclipse.org/downloads/packages/eclipse-classic-371/indigosr1), and then perform the following steps to download and install this package:
Free Download Mobile Application
- Select the appropriate distribution file for your platform by clicking one of the links in the Download Links box on the right side of this page. For example, I clicked Windows 32-bit.
- Click a download link, select a download mirror, and save the distribution file to your harddrive. For example, I saved eclipse-SDK-3.7.1-win32.zip to my hard drive.
- Unarchive the distribution file and move the eclipse home directory to a convenient location. For example, I moved eclipse to my C:Program Files directory.
- Create a desktop shortcut to the eclipse application located in the eclipse home directory. This shortcut makes it convenient to launch the Eclipse IDE.
Start Eclipse. Figure 20 reveals a splash screen identifying this IDE. Furthermore it reveals the Workspace Launcher dialog box, which lets you choose a workspace folder for storing the current session’s Eclipse projects.
Note: An Eclipse workspace is a disk location that’s associated with a workbench instance, where a workbench is a runtime instance of the Eclipse IDE. The workspace contains files, folders, and other resources that comprise your projects.
Figure 20: Check the checkbox to avoid being prompted each time you start Eclipse.
Click OK to close Workspace Launcher. Eclipse responds by performing some initialization, and then it presents its main window, as shown in Figure 21.
Figure 21: The Eclipse 3.7.1 IDE main window initially presents a Welcome tab.
The main window is divided into a menubar, a toolbar, a workbench area (initially presenting a Welcome tab), and a statusbar.
Download Eclipse For Mobile Application Development System
Install the ADT Plugin
The Android Development Tools (ADT) Plugin is a special Eclipse plugin that facilitates app development. Although you can develop Android apps without the ADT Plugin, you’d have to work directly with Android’s command-line tools. You’ll find that this plugin makes it much faster and easier to create, debug, and otherwise develop these apps.
The ADT Plugin offers the following benefits:
- It gives you access to other Android development tools from inside the Eclipse IDE. For example, ADT lets you access the many capabilities of the Dalvik Debug Monitor Server (DDMS) tool, which lets you take screenshots, set breakpoints, manage port-forwarding, and view process and thread information directly from Eclipse.
- Its New Project Wizard helps you quickly create and setup all of the fundamental files that you’ll need for a new Android app.
- It automates and simplifies the app-building task.
- Its Android code editor helps you write valid XML for your Android manifest and resource files.
- It facilitates exporting your project as a signed APK, which can then be distributed to users.
Assuming that the Eclipse IDE is running, complete the following steps to install the latest ADT Plugin revision:
- Select Install New Software from the Help menu.
- Click the Add button on the resulting Install dialog box’s Available Software pane.
- On the resulting Add Repository dialog box, enter Android Plugin into the Name textfield and https://dl-ssl.google.com/android/eclipse/into the Location textfield. Click the OK button.
- After a few moments, you should see Developer Tools in the tree-based list near the middle of the Install dialog box. Expand this node and check the checkbox to its left. You’ll discover that the Android DDMS, Android Development Tools, Android Hierarchy Viewer, and Android Traceview subnodes are also checked. Click the Next button.
- After a few moments, an Install Details pane appears and signifies that these four items will be installed. Click Next, and the Review Licenses pane appears. Read and accept the terms of these license agreements and click the Finish button.
- An Installing Software dialog box appears, giving you the option of installing these items in the background. If you encounter a Security Warning dialog box, click the OK button to close this dialog box and continue.
- Eclipse presents a Software Updates dialog box that prompts you to restart this IDE. Click the Restart Now button. After Eclipse restarts, you will probably see an Android SDK Verification dialog box stating that Eclipse cannot find the C:android-sdk-windows folder. This is not surprising, because the folder is named C:android-sdk (as specified earlier in this course when installing the SDK). Ignore this error; you will fix it shortly. Click the OK button to dismiss this dialog box.
- Select Preferences from the Window menu to open the Preferences dialog box. For Mac OS X, select Preferences from the Eclipse menu.
- Select the Android node in the left panel of this dialog box.
- Click the Browse button beside the SDK Location textfield, and then locate your downloaded SDK’s home directory (e.g., C:android-sdk) via the resulting Browse For Folder dialog box.
- After closing Browse For Folder, click Apply followed by OK on the Preferences dialog box to complete installation.
Develop and Run W2A with Eclipse/ADT
Now that you’ve installed Eclipse and the ADT Plugin, let’s revisit W2A by developing this app in this new environment. We’ll begin by creating a W2A project, which is accomplished by performing the following steps:
- Start Eclipse if not running.
- Select New from the File menu and Project from the resulting popup menu.
- On the resulting New Project dialog box, expand the Android node in the wizard tree (if not expanded), choose the Android Project branch below this node, and click the Next button.
- On the resulting New Android Project dialog box, enter W2A into the Project Name textfield – the entered name identifies the current workspace directory in which this project is stored. Continuing, select the Create new project in workspace radio button if not selected, and click the Next button.
- On the resulting Select Build Target pane, ensure that Android 2.3.3 is checked under Build Target and click Next.
- On the resulting Application Info pane, enter Welcome to Android into the Application name textfield, replacing the default W2A value. This human-readable title appears as the app’s icon’s caption on the Android device’s app launcher screen. (You could leave W2A alone if desired.) Next, enter ca.tutortutor.w2a into the Package Name textfield, check the Create Activity checkbox if not checked, enter W2A as the name of the app’s starting activity in the textfield that appears beside this checkbox, and make sure that 10 (Android 2.3.3) is current in the Minimum SDK drop-down listbox – it probably will be current. Click the Finish button.
Eclipse creates a W2A directory within its workspace directory. W2A contains the following subdirectories and files:
- .settings: This directory contains org.eclipse.jdt.core.prefs. This file records project-specific settings.
- assets: This directory stores an unstructured hierarchy of files. Anything placed in this directory can be retrieved by an app via a raw byte stream.
- bin: This directory stores the created APK file.
- gen: This directory stores the generated R.java file within a subdirectory structure that reflects the package hierarchy (catutortutorw2a).
- res: This directory stores app resources in various subdirectories.
- src: This directory stores app source code according to a package hierarchy.
- .classpath: This file stores the project’s classpath information so that external libraries on which the project depends can be found.
- .project: This file contains project-oriented information such as the name of project and what builders it contains.
- AndroidManifest.xml: This file contains W2A’s manifest information.
- proguard.cfg: This file contains configuration data for the ProGuard obfuscation tool.
- project.properties: This file contains project settings.
Close the Welcome tab. Eclipse responds by presenting Figure 22’s workbench.
Figure 22: The workbench features the solitary W2A project.
Ide For Mobile Application Development
The workbench is organized around a menubar, a toolbar, several windows such as Package Explorer and Outline, a blank area that’s reserved for editor windows, and a statusbar.
Package Explorer appears on the left and presents an expandable list of nodes that identify the current workspace’s projects. To learn how Eclipse organizes the W2A project, click the “+” icon on the W2A node’s left. Figure 23 reveals an expanded project hierarchy.
Figure 23: W2A’s hierarchy is organized into src, gen, Android 2.3.3, assets, bin, and res directories; as well as AndroidManifest.xml and two configuration files.
Expand the src node followed by the resulting ca.tutortutor.w2a node. Double-click the resulting W2A.java node and you’ll see Figure 24’s editor window.
Figure 24: The editor for the W2A.java source file displays skeletal source code.
Replace Figure 24’s skeletal source code with the contents of Listing 1 (see Lesson 3). Then select Run or Run Last Launched from the menubar’s Run menu (Run appears instead of Run Last Launched if the project has not previously run). On the resulting Run As dialog box (which appears the first time you run the project), select Android Application and click OK. The W2A project is built before it runs.
Figure 25 shows you what you probably will see, especially if you’re running on Windows XP.
Figure 25: Attempting to run W2A may produce an unexpected crash.
Unfortunately, software is often poorly written and leads to program crashes. In this case, the culprit is probably a buggy ADT Plugin.
After some research and experimentation, I was able to solve this problem. I had to change the name of Android’s home directory from android-sdk to android, update my PATH environment variable to reflect this change, and disable the snapshot setting in MyAVD. I accomplished this last task by using AVD Manager to delete MyAVD, recreate MyAVD without enabling the snapshot, and start MyAVD (making sure to check the Wipe user data checkbox on the Launch Options dialog box). I then closed the emulator, started Eclipse, and attempted to run W2A. This time, I was greeted by what you see in Figure 26.
Figure 26: W2A is successfully installed and run on the emulator in the context of Eclipse.
Review
The following review questions help you test your mastery of Lesson 7’s material:
- What Eclipse packages does Google recommend for developing Android apps?
- What benefits does the ADT Plugin provide?