Setting Up Your Development Environment
Java developers, especially those using Eclipse, will have an easy transition to the Android development world. Most apps are written in Java, and it’s typical for development to be done within the Eclipse IDE due to the tooling support provided by Google (although everything can be done outside the IDE from the command line). Android development is supported on the three major operating systems:
- Windows (XP, Vista, and 7)
- Mac OS X
- Linux
1. In order to set up your environment, you’ll need to download and install the following:
- A Java Development Kit (JDK 6 or JDK 7) – the Java Runtime Environment (JRE) alone is not enough. You can download the specific JDK for your system from http://www.oracle.com/technetwork/java/javase/downloads/index.html.
- Eclipse 3.5 (Galileo), which can be downloaded from http://www.eclipse.org/downloads/. “Classic” is the recommended version.
- Android SDK Tools available from http://developer.android.com/sdk/index.html. Take note where this is installed or unzipped for the next step.
- Android Developer Tools (ADT)—Eclipse Plugin, which needs to be installed from inside Eclipse:
- From the Help menu, click on Install New Software, then select Add.
- In the dialog box, enter ADT Plugin for the Name and https://dl-ssl.google.com/android/eclipse/ in Location; then press OK.
- Select Developer Tools and click Next, and Next again when presented with the items to be installed.
- Read and accept the license terms, and click Finish.
When the installation is complete, restart Eclipse.
2. Now configure the installed plugin by clicking on the Window menu and selecting Preferences. If you’re on a Mac, select Eclipse -> Preferences.
Select Android, and then for the SDK Location, browse to where you installed the Android SDK Tools, and select that. Click Apply, then OK.
Using the tools now installed, you need to install the SDK components. This is done using the Android SDK Manager found under the Window menu in Eclipse. Launch the manager and select packages you want to download. Then select Documentation, SDK Platform Android 2.3, and Samples for SDK API 9; click Install Packages.
3. Running the Emulator
Now that you have all the tools required to started developing and running Android apps, you need to create a virtual device for your apps to run on in the Android Emulator. An Android Virtual Device(AVD) defines a device profile that the emulator can use when running your apps. You can also create multiple AVDs to test against, which comes in handy when you want to test your app on different-sized screens and various versions of the SDK.
To create an AVD, select Virtual Devices from the AVD Manager, and click New. Give the device a name and select the target SDK from the drop-down. Here, you’re also able to select different screen sizes and emulator storage sizes; for now, we’ll leave everything as the default and click Create AVD.
4. Creating a Project
Leaving the Emulator running, restart Eclipse so as to create our first Android project. Once Eclipse has finished loading, go to File -> New -> and select Android Application Project.
Fill in the Project and Application names, and then enter a package name for the app. Note: This package will not only become the top-level Java package for your source files, but also provides a unique identifier for your app. No two apps can have the same package identifier installed on the phone at the same time, and the same goes for apps submitted to the Play Store.
5. Now Configure launcher icon (the icon of your app), this icon will be used to launch your application from launcher screen or Application Menu.
- Select foreground: image/clip art/text
- Foreground scalling: crop/center
- Shape: none/square/circle
- Backgroud: and foreground: color
- Click next create an activity
6. select blank activity and click next to provide details of your activity
- Activity name: (first character should be capital)
- Layout name: (all character should be small)
- Navigation Type:none
8. Congrats your first program is created. Because eclipse itself creates Textview with text Hello World we do not need to add it in layout.
10. It will ask for certain options to run as but you have to select Android Application because we are creating android application and click OK, now your hello world program will run on AVD that we launched already.
Update: you can skip 1st and 2nd step by downloading ADT Bundle.