Mobile Zone is brought to you in partnership with:

I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 639 posts at DZone. You can read more from them at their website. View Full User Profile

Android 101: System Setup

10.06.2010
| 9997 views |
  • submit to reddit

In the previous article in this series, we looked at the basic concepts of the Android architecture. In this article, we'll look at how to get Android setup on your system. I'll make the assumption that you already have Java 5+ installed. To make life easier for yourself, you should also have Eclipse installed as your development IDE.  

Setting Up The Android SDK

  • Download the Android SDK from http://d.android.com/sdk/index.html.
  • Once downloaded, extract the zip file to a location on your hard drive. Optionally, you can add the location of the SDK to your system PATH.
  • Run the SDK setup program. On Windows, this will be SDK Manager.exe while on other platforms you will need to run tools/android. This program will allow you to install SDK components such as documentation, platforms, add-on libraries and USB drivers. 

  • Typically you will want to select everything here so that you can write applications for any Android target.

Development Tools 

The next part of your setup is to install the Android Development Toolkit in your Eclipse instance. The best way to do this is to use the Update Manager under the Help/Install New Software menu. Just add a new update site pointing to https://dl-ssl.google.com/android/eclipse.

 

 

 

Once the install completes you'll need to restart Eclipse. 

Your First Android Project 

Now you're ready to really get into Android development.

First you'll have to let Eclipse know where to find the Android SDK. Go to the preferences dialog, and click on the Android item to do this: 

Your one last step is to ensure you have an AVD (Android Virtual Device) from which to run your application. You can do this from the AVD manager: 

 

When you use the New Project wizard, you'll have the option to create an Android project: 

From here you can create a project that has a particular Android SDK targetted: 

If you click on next, you will also be able to create an Android test project that will allow you to test out your app. 

Inside the project you will see the source for your newly created activity: 

package com.dzone.android.app;

import android.app.Activity;
import android.os.Bundle;

public class FirstActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

We'll change this around a little, creating our own view to use: 

package com.dzone.android.app;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class FirstActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView view = new TextView(this);
view.setText("A New App");
setContentView(view);
}
}

To see if this works, click on Run As / Android application. This will launch the Android emulator and start up your newly created application

Now that you've got your system properly set up, the next few articles in this series will bring you through the process of writing your own application.

 

 

 

Tags: