You are on page 1of 5

Required:

JDK 6 or above
Eclipse Juno
Android SDK 4.1
ADT plugin for eclipse
You can find quality tutorials at Commonsware's Android Programming Tutorials
There are several tutorials at developer.android.com which are good place to start.
The Notepad tutorial shows you how to build up a simple notepad application.
Have a look at http://androidjava.wordpress.com/.
Here are some more step by step tutorials with screen shots and examples
Getting Started with Android Development
Building an android application
Android Activity Life cycle:LogCat and exception handling Here is the Hello World tutorial on
developer.android.com
Android Activity Life Cycle
How Not to Run Your Project

When you go to run your project, be sure that an XML file is not the active tab in the editor. Attempting to
"run" this will result in a .out file being created in whatever directory the XML file lives in (e.g.,
res/layout/main.xml.out). To recover, simply delete the offending .out file and try running again, this
time with a Java file as the active tab.

Your Android SDK should already include the latest Android Support Library. It's included with
the ADT Bundle but if you're using a different IDE, you should have installed it during the
Adding Platforms and Packages step. When using the templates in Eclipse, the Support Library
is automatically added to your app project (you can see the library's JAR file listed under
Android Dependencies). If you're not using Eclipse, you need to manually add the library to your
project
Run on a Real Device
If you have a real Android-powered device, here's how you can install and run your app:
1. Plug in your device to your development machine with a USB cable. If you're developing
on Windows, you might need to install the appropriate USB driver for your device. For
help installing drivers, see the OEM USB Drivers document.
2. Enable USB debugging on your device.
o On most devices running Android 3.2 or older, you can find the option under
Settings > Applications > Development.
o On Android 4.0 and newer, it's in Settings > Developer options.
Note: On Android 4.2 and newer, Developer options is hidden by default. To
make it available, go to Settings > About phone and tap Build number seven
times. Return to the previous screen to find Developer options.
To run the app from Eclipse:
1. Open one of your project's files and click Run from the toolbar.
2. In the Run as window that appears, select Android Application and click OK.
Eclipse installs the app on your connected device and starts it.
Or to run your app from a command line:
1. Change directories to the root of your Android project and execute:
ant debug
2. Make sure the Android SDK platform-tools/ directory is included in your PATH
environment variable, then execute:
adb install bin/MyFirstApp-debug.apk
3. On your device, locate MyFirstActivity and open it.
Run on the Emulator
Whether you're using Eclipse or the command line, to run your app on the emulator you need
to first create an Android Virtual Device (AVD). An AVD is a device configuration for the Android
emulator that allows you to model different devices.

Figure 1. The AVD Manager showing a few virtual devices.
To create an AVD:
1. Launch the Android Virtual Device Manager:
a. In Eclipse, click Android Virtual Device Manager from the toolbar.
b. From the command line, change directories to <sdk>/tools/ and execute:
android avd
2. In the Android Virtual Device Manager panel, click New.
3. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a
skin (HVGA is default).
4. Click Create AVD.
5. Select the new AVD from the Android Virtual Device Manager and click Start.
6. After the emulator boots up, unlock the emulator screen.
To run the app from Eclipse:
1. Open one of your project's files and click Run from the toolbar.
2. In the Run as window that appears, select Android Application and click OK.
Eclipse installs the app on your AVD and starts it.
Or to run your app from the command line:
1. Change directories to the root of your Android project and execute:
ant debug
2. Make sure the Android SDK platform-tools/ directory is included in your PATH
environment variable, then execute:
adb install bin/MyFirstApp-debug.apk
3. On the emulator, locate MyFirstActivity and open it.

// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
----------------------
}
Using the SDK_INT to prevent older system's from executing new APIs works in this way on
Android 2.0 (API level 5) and higher only. Older versions will encounter a runtime exception.
Sample Code:
-----------------------------------

<TableLayout>
<TableRow>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
</TableRow>
<TableRow>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
</TableRow>
<TableRow>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal">
<include layout="@layout/form_fields" />
</LinearLayout>
</TableRow>
</TableLayout>
Then your @layout/form_fields looks like this:
<LinearLayout
android:orientation="vertical">
<TextView />
<EditText />
<Spinner />
</LinearLayout>




While updating build tools using SDK manager, Eclipse (Access is denied)
Solution Right click eclipse.exe and select Run as Administrator
Manually downloading the package also helps.
After downloading, install the same.

You might also like