This post details my first adventure into developing for the Android platform and the steps taken to get the HelloWorld application to run.
- Download the Linux SDK from: http://developer.android.com/sdk/index.html
- Extract the archive and take note of the directory
- Install Eclipse (`apt-get install eclipse`)
- Install Eclipse plugin
- Help->Install Software
- Add repository: https://dl-ssl.google.com/android/eclipse
- Select Developer Tools
- Read and accept licenses
- Configure Eclipse
- Windows->Preferences->Android
- Set SDK Location
- Select OK
- Setup SDK and Virtual Device
- From Eclipse: Window->Android SDK and AVD Manager->Available Packages
- Select Android Repository->Install Selected
- Select Virtual devices->New: Name the device and select the target API version
- Create Android Project in Eclipse
- Project name: HelloAndroid
- Application name: Hello
- Package name: com.example.helloandroid
- Create Activity: HelloAndroid
- Build Target: Same as the target as selected for Virtual Device
- Add the code below to src/com.example.helloandroid/HelloAndroid.java
- Create a new Runtime configuration
- Run->Run Configurations->Android->New
- Project: HelloAndroid
- Select Target tab and choose the Virtual Device configured earlier
- Run!
- After a couple of minutes the emulator should boot and display the HelloWorld application (You may need to unlock the screen first)
HelloAndroid.java
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}
For more information see the Android development documentation:
http://developer.android.com/sdk/installing.html
http://developer.android.com/sdk/eclipse-adt.html#installing
http://developer.android.com/resources/tutorials/hello-world.html