Eclipse IDE
Eclipse IDE
SDK (Software Development Kit) - A set of tools and libraries that allow the user to create an
application based on a product.
ADT (Android Development Tools) – A plugin for eclipse that extends the Eclipse IDE by
providing more tools to develop Android Applications
AVD (Android Virtual Device) – An Android emulator that allows you to simulate how the
application will run on an actual Android device.
JDK (Java SE Development Kit) – A popular Java SDK that is used to program Android
applications.
2 Objective
This document will demonstrate how to create an Android application using the Eclipse
IDE. It is design to guide the user through configuring his or her computer for Android
development. It also walks the user through creating and running an Android
application.
3 System Requirements
Make sure that the computer being used for development meets the software and hardware
requirements for the Android SDK and Eclipse.
http://developer.android.com/sdk/requirements.html
2
4 Installation and Configuration
3
Home screen of Eclipse for Java Developers
4
4.3 Install ADT plugin for eclipse
3. Then put a check mark next to the Developer Tools and click Next.
4. On the next screen it will show all of the tools that will be downloaded. Click
Next.
5. Read and agree the license agree to the license agreements then click Finish.
6. Restart Eclipse.
1. Click on Window->Preferences->Android.
2. Click on Browse to find the location of your SDK directory.
3. Click Apply, and then OK.
5
4.5 Adding SDK Components.
1. Click on Window->Android SDK Manager.
2. This will allow you to choose the Android platform versions, add-ons tools and
other components. Choose the version of Android that you would like you
application to work on.
Note: This application note will be using 2.3.3.
3. Click Install Selected and wait for the components to down. When the
download is finished, verify and accept the new components.
6
2. Type in the Name of the AVD and choose a Target. The target is the version of
the Android SDK that you would like to run on the emulator.
3. Click Create AVD.
2. Select an Android Project from the Android Folder and press Next.
3. Fill in the details of your Android application.
a. Project Name: The project name and folder that Eclipse will store the
project files
b. Build Target: The version of the Android SDK that will be used when you
build your program. Select a platform that is equal to or lower than the
target chosen for the AVD.
c. Application Name: This is the name of the application.
d. Package Name: The namespace that all of the source code will reside
under.
e. Create Activity: The name for that class stub that is generated by the
plugin.
4. The values that are used in this example are:
a. Project Name: SampleApp
b. Build Target: 2.3.3
c. Application Name: SampleApp
d. Package Name: com.sample.example
e. Create Activity: SampleApp
5. Click on Finish.
7
Figure 7.10 Screen after project creation.
8
6.2 Editing the layout
2. Open main.xml which is located in res->layout->main.xml. This file will hold the
layout of the application which includes labels, textboxes, and other UI
interfaces.
a. Main.xml has a GUI and a raw xml view. The GUI has many different
widgets that you can drag and drop onto the screen.
b. From the form widgets drag a Large text label and from Text Fields drag
the first and last name text box onto the phone screen.
c. Then go to the raw xml view and add android:text=”@string/name” to the
TextView. You can see the final raw xml below. This will take the text that is
labeled “name” in the strings.xml and display it for the TextView.
9
6.3 Editing the the java code
1. Open SampleApp.java from the left hand side.
2. At the top add the following import statements
a.
b. This allows you to use the functions located in these files.
3. Next we need to add the code to get the information from the text box and display it.
The following code gets the name from the text box and forms it into a string that says
“Hello [name]”. Then it uses the the toast class to display the message to the user when
enter is pressed. Enter the following code at the end of onCreate.
10
7 Running the Application
1. Click on the green circle with the white arrow.
2. Choose the AVD that we created in a previous step.
3. The android AVD will load and the program will run.
4.
5. This is what will happen after you enter your Name and press enter.
6.
11
7. You have successfully completed an android application.
8 Conclusion
Congratulations you have successfully created an Android application. While this application
note taught you how to create a basic application you can use the techniques you learned to
expand on your application and turn it into something more powerful.
9 Resources
http://www.developer.android.com
http://www.eclipse.org/downloads/
http://www.oracle.com/technetwork/java/javase/downloads/index.html
12