Skip to Content

This blog is a step-by-step guide in building your first android application.

0.1.

Install JDK

 Install JDK via the following link :

 

http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html     

Extract the contents of the ZIP file

 

0.1.

Install Eclipse

Install Eclipse via the following link :

 

http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/indigor

              >  Download the ZIP file to your local folder

              >  Extract the contents of the ZIP file

              >  Double-click on eclipse.exe to start the eclipse

              >  Enter the folder for the Workspace, and click OK

image

</p><ul><li>Install the Android SDK</li></ul><p>Install the SDK via the following link :</p><p> [http://developer.android.com/sdk/index.html  | http://developer.android.com/sdk/index.html]</p><p> </p><ul><li>Install Eclipse ADT(Android Development Tools) Plug-In*

                     >  Start Eclipse

                     > Click on Help -> Install New Software

                      image

                    > Click “Add” in the right corner

 !https://weblogs.sdn.sap.com/weblogs/images/33546/Add.png|height=129|alt=image|width=445|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Add.png|border=0!

                    > In the “Add Repository” dialog, enter the path as shown below,    and click OK

 !https://weblogs.sdn.sap.com/weblogs/images/33546/AddRepository.png|height=81|alt=image|width=362|src=https://weblogs.sdn.sap.com/weblogs/images/33546/AddRepository.png|border=0!

                    > Select the “Check Box” against “Developer Tools” and click “Next”

                    > In the next window, you’ll see a list of the tools to be downloaded.

                    >

Click Next.

                    >

Click Finish.

                    > When the installation completes, restart Eclipse.

 

Configure ADT Plug-In                    > Start Eclipse

                    > Select Window -> Preferences

                    > Select “Android” from the left panel, enter the downloaded SDK location and click “Apply” and then “OK”

 !https://weblogs.sdn.sap.com/weblogs/images/33546/AndroidPreferences.png|height=273|alt=image|width=448|src=https://weblogs.sdn.sap.com/weblogs/images/33546/AndroidPreferences.png|border=0!

 

0.1.

Configure the Android Simulator               > Start Eclipse 

               > Click on Window -> Android SDK and AVD Manager

               > Select “Virtual Devices” in the left panel and click on “New”

               > In the dialog , enter as shown below

 !https://weblogs.sdn.sap.com/weblogs/images/33546/Device.png|height=407|alt=image|width=303|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Device.png|border=0!

0.1.

Test your configuration by writing a simple application               > Start Eclipse

               > Click on New -> Project

               > Select “Android Project” and click on “Next”

               > Enter the attributes of the project and click “Finish”

 !https://weblogs.sdn.sap.com/weblogs/images/33546/ProjectAttributes.png|height=500|alt=image|width=373|src=https://weblogs.sdn.sap.com/weblogs/images/33546/ProjectAttributes.png|border=0!

         

         > The project “myFirstApplication” will show the nodes as shown below

 

 !https://weblogs.sdn.sap.com/weblogs/images/33546/myFirstApplication.png|height=185|alt=image|width=215|src=https://weblogs.sdn.sap.com/weblogs/images/33546/myFirstApplication.png|border=0!

            

            > Double-Click on AndroidManifest.xml

 

image

 

         > Click on the tab “Instrumentation”, and then “Add”

image

 

         > Select “Instrumentation” in the dialog

         > Click on “Browse” against the name

image

 

         > Wait for the system to find a matching runner, and then select the matching item, and click OK

image

         > Select the package, and then click on “Save”

 !https://weblogs.sdn.sap.com/weblogs/images/33546/Instrumentation.png|height=198|alt=image|width=438|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Instrumentation.png|border=0!

 

 *        Now lets write a simple application to display a text , on click of a button</p><p>         > Lets add a button and a Textbox in the layout</p><p>         > Click on “Main.XML”, and modify the XML as shown below</p><p>!https://weblogs.sdn.sap.com/weblogs/images/33546/Main.PNG|height=227|alt=image|width=192|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Main.PNG|border=0!</p><p>*XML Layout **********************************************</p><p><?xml version=”1.0″ encoding=”utf-8″?><br /><LinearLayout xmlns:android=”[http://schemas.android.com/apk/res/android | http://schemas.android.com/apk/res/android]”<br />    android:orientation=”vertical”<br />    android:layout_width=”fill_parent”<br />    android:layout_height=”fill_parent”<br />    ><br /><TextView  <br />    android:layout_width=”fill_parent” <br />    android:layout_height=”wrap_content” <br />    android:text=”Hi Android”<br />    />    <br /><TextView  <br />    android:id=”@id/result” <br />    android:layout_width=”fill_parent” <br />    android:layout_height=”wrap_content” <br />    android:text=””</p><p>    /><br /><Button <br />  android:text=”Display Text” <br />  android:id=”@id/button_text” <br />  android:layout_width=”wrap_content” <br />  android:layout_height=”wrap_content”><br />  </Button>    <br /></LinearLayout></p><p>************************************************************

image

 

    **  Note that the name of the text view is “result” and name of the button is “button_text”

Lets go back and write some code to finish our application

         > Click on “myFirstApplicationActivity” and write the following code :

 

image

 

    • Start of  Code **********************************************</p><p>package myFirstApplication.com;<br />import android.app.Activity;<br />import android.os.Bundle;<br />import android.view.;

import android.widget.Button;

import android.widget.TextView;

public class MyFirstApplicationActivity extends Activity {

 private TextView result; 

    /** Called when the activity is first created. /<br />    @Override<br />    public void onCreate(Bundle savedInstanceState) {<br />        super.onCreate(savedInstanceState);<br />        setContentView(R.layout.main);<br />        result = (TextView)findViewById(R.id.result);<br />        Button button_text = (Button)findViewById(R.id.button_text);<br />        button_text.setOnClickListener(new Button.OnClickListener() <br />         { <br />         public void onClick (View v)<br />          { <br />          display_text(); <br />             }<br />         }<br />        );        <br />    }<br />    public void display_text()<br /> {<br />       result.setText(“[www.sap.com | http://www.sap.com]”);</p><p> }      <br />}</p><p>**************************************************************

image

****************************************************************

 

         > Run the application by clicking on “Run” in the menu bar and then select “Android Application” in the dialog

 !https://weblogs.sdn.sap.com/weblogs/images/33546/RunasAndroid.png|height=330|alt=image|width=206|src=https://weblogs.sdn.sap.com/weblogs/images/33546/RunasAndroid.png|border=0!

   >  Wait for a few seconds until , we see the following screen :

 !https://weblogs.sdn.sap.com/weblogs/images/33546/Android.png|height=446|alt=image|width=459|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Android.png|border=0

 

Wait for about 40-60 secs to see your application, then click on the home in the right hand side, or unlock the application

Here it is !!!  “myFirstApplication”.

!https://weblogs.sdn.sap.com/weblogs/images/33546/andapps.PNG|height=500|alt=image|width=479|src=https://weblogs.sdn.sap.com/weblogs/images/33546/andapps.PNG|border=0!

 

!https://weblogs.sdn.sap.com/weblogs/images/33546/Firstapps.PNG|height=177|alt=image|width=379|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Firstapps.PNG|border=0!

 

 

Click on “myFirstApplication”.

!https://weblogs.sdn.sap.com/weblogs/images/33546/Executefirstapps.PNG|height=294|alt=image|width=457|src=https://weblogs.sdn.sap.com/weblogs/images/33546/Executefirstapps.PNG|border=0!

 

Click on the button “Display Text” to see the text www.sap.com (http://www.sap.com).

 

!https://weblogs.sdn.sap.com/weblogs/images/33546/result.PNG|height=259|alt=image|width=334|src=https://weblogs.sdn.sap.com/weblogs/images/33546/result.PNG|border=0!

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Raj Govender
    Nicely written!

    To install app on your Android phone just connect it to your computer. When you run the app again Eclipse will find it automatically and install it on the phone.

    Raj

    (0) 
  2. Harish Padikkad Mohananarayanan
    A nice blog, indeed, a easy to find, one place where i can see all the steps for developing first Android app. I had to go through more than 3 documents during my development of “Hello World!” app 🙂 ..Thank you Girish.
    (0) 

Leave a Reply