TABLE OF CONTENTS (HIDE)

Android SDK

How to Install and Get Started

Introduction

Android Robot

Android is an Operating System for mobile devices developed by Google, which is built upon Linux kernel. Android competes with Apple's iOS (for iPhone/iPad), RIM's Blackberry, Microsoft's Windows Phone (previously called Windows Mobile), Sambian OS, and many other proprietary mobile OSes.

Android Platform

Android is based on Linux with a set of native core C/C++ libraries. Android applications are written in Java. However, they run on Android's own Java Virtual Machine, called Dalvik Virtual Machine (DVM) (instead of JDK's JVM) which is optimized to operate on the mobile devices.

Android Stack

The mother site for Android is http://www.android.com. For developers, visit http://developer.android.com to download the SDK, Android Training, API Guides and API documentation.

How to Install Android Software Development Kit (SDK)

Installing all the necessary software needed for Android programming takes times - from 15 minutes to 3 hours - depending on your luck!!!

Android Software Development Kit (SDK) runs on top of Eclipse with Android Development Tool (ADT) Plugin; and JDK. In other words, you need

  1. JDK,
  2. Eclipse,
  3. ADT Plugin for Eclipse, and
  4. Android SDK.
Pre-Installation Check List
  1. Before installing Android SDK, you need to install Java Development Kit (JDK). Read "How to install JDK".
  2. Read the "Android Training" @ Android Developers (http://developer.android.com). There are three main menus: "Design", "Develop", and "Distribute". Choose "Develop", you can find the Android "Training", "API Guides", "Reference" and "Tools". For beginners, browse through the "Training".
Android SDK Installation Packages

There are two options to install Android SDK:

  1. Install the "ADT Bundle", which includes everything you need to write Android apps (i.e., Eclipse + ADT Plugin for Eclipse + Android SDK). This requires a huge download of about 500MB. [However, the Bundle's SDK version is slightly behind. At the time of writing (end of March 2014), Bundle is 22.3, but SDK is 22.6.]
  2. If you have already installed Eclipse, you could install the ADT plugin for Eclipse and Android SDK on top of the existing Eclipse.

Installation Option (1): Installing ADT Bundle (Recommended)

Step 1: Download the "ADT Bundle" Zip File

Goto "Android Developer" @ http://developer.android.com/index.html and select "Get the SDK".

  • For Windows: Select "Download the SDK - ADT Bundle for Windows". Choose either "32-bit" or "64-bit" and "Download".
  • For Mac: Expand "Download for Other Platforms" ⇒ Under "ADT Bundle", Select "Mac OS X 64-bit".
Step 2: Unzip

Unzip the download file into a folder of your choice, e.g., "d:\myproject" (for Windows) or "/Applications" (for Mac). Do NOT use a directory name containing space or special characters!!!

Installation Option (2): Installing on Existing Eclipse (Skip if you choose option 1)

Step 0: Check that Eclipse has been installed
Step 1: Download the Android SDK

Goto http://developer.android.com/sdk/index.html. ⇒ Expand "Download For Other Platforms" ⇒ Under "SDK Tools Only" ⇒ Download the appropriate SDK Tools for your operating platform. Choose the ZIP version, e.g., android-sdk_r22.6-windows.zip (104 MB).

Step 2: Install Android SDK

Unzip the downloaded file into a folder of your choice. Take note of the installed directory. Hereafter, I shall denote the android installed directory as <ANDROID_SDK_HOME>.

Step 3: Install Android Platforms and Add-ons via "SDK Manager"

The Android SDK comprises 2 parts: the "tools" and the "Platforms & Add-ons". The previous step installed the basic "tools", which are executables that support app development. The "Platforms & Add-ons" consist of ALL Android platforms (from Android 1.x to 4.x) and various Google Add-ons (such as Google Map API), which could be selectively installed.

Now, we have to setup our Android "Platforms & Add-ons".

  1. Launch Android's "SDK Manager", which is responsible for managing the Android components. Launch the SDK manager by running (double-clicking) "SDK Manager.exe" under the Android installed directory.
  2. In "Add Platforms and Packages", select your target Android platforms and add-ons packages. For novices, select "Android SDK Platform-Tools", and at least one (the latest) Android platform (e.g., Android 4.4 (API 19)) ⇒ "Install".
Step 4: Install Eclipse Android Development Tool (ADT) Plugin

I suppose that you have installed Eclipse.

  1. Launch Eclipse.
  2. Install Eclipse ADT: From Eclipse's "Help" menu ⇒ "Install New Software..." ⇒ In "Work with", enter https://dl-ssl.google.com/android/eclipse/ ⇒ Check ALL boxes ⇒ Next ⇒ Finish ⇒ Restart Eclipse to use ADT plugin.
  3. Configure Eclipse ADT: From Eclipse's "Window" menu ⇒ Preferences ⇒ Android ⇒ In "SDK Location", select the Android SDK installed directory (that you have chosen in Step 2).
(Optional) Step 5: Setup PATH for utilities adb.exe and emulator.exe

To run the utilities "adb.exe" (Android Debug Brige) and "emulator.exe" from command-line, you need to include their path in the environment variable PATH. The "adb.exe" is kept in directory "<ANDROID_SDK_HOME>\platform-tools", while "emulator.exe" is kept in "<ANDROID_SDK_HOME>\tools". Add both directories to the PATH.

For Windows: Start "Control Panel" ⇒ "System" ⇒ (Vista/7) "Advanced system settings" ⇒ Switch to "Advanced" tab ⇒ "Environment variables" ⇒ Choose "System Variables" for all users (or "User Variables" for this login user only) ⇒ Select variable "PATH" ⇒ Choose "Edit" for modifying an existing variable ⇒ In variable "Value", APPEND your <ANDROID_SDK_HOME>\platform-tools directory (e.g., "d:\bin\android-sdk\tools"), followed by a semi-colon ';', IN FRONT of all the existing path entries. DO NOT remove any existing entry; otherwise, some programs may not run.

Add the "<ANDROID_SDK_HOME>\tools" directory to the PATH too.

Write your First Android App

Android apps are written in Java, and use XML extensively. I shall assume that you have basic knowledge of Java programming and XML.

Take note that Android emulator is slow - VERY VERY VERY SLOW!!!

Hello-world

Step 0: Read

Goto "Android Training" @ http://developer.android.com/training/index.html. Read "Get Started", "Building your first app".

Step 1: Create a new Android Project
  1. Launch Eclipse. For "ADT Bundle", run "eclipse.exe" under the "eclipse" sub-directory. Choose a NEW workspace (don't use you previous workspace).
  2. Close the "Welcome" screen, if it appears.
  3. From "File" menu ⇒ New ⇒ Project... ⇒ "Android Application Project" ⇒ Next.
  4. The "New Android Project" dialog appears:
    1. In "Application Name": Enter "Hello Android" - this is the Android application name that shows up on the real device.
    2. In "Project Name": Enter "HelloAndroid" (default) - this is the Eclipse's project name.
    3. In "Package Name": Enter "com.example.helloandroid" (default).
    4. In "Minimum Required SDK": Select "API 8: Android 2.2 (Froyo)" (default) - almost all of the Android devices meet this minimum requirement.
    5. In "Target SDK" and "Compile With": Select the latest Android version.
    6. For "Theme", use the default ⇒ Next.
  5. The "Configure Project" dialog appears ⇒ Use the defaults ⇒ Next.
  6. The "Configure Launcher Icon" dialog appears, which allows you to set the application's icon to be displayed on the devices ⇒ Use the defaults ⇒ Next.
  7. The "Create Activity" dialog appears ⇒ Check "Create Activity" Box (default) ⇒ Select "Blank Activity" (default) ⇒ Next.
  8. The "Blank Activity" dialog appears.
    1. In "Activity Name": Enter "MainActivity" (default).
    2. In "Layout Name": Enter "activity_main" (default) ⇒ Finish.
  9. By default, a hello-world app is created.
Step 2a: Setup Emulator (or Android Virtual Device (AVD))

Android Virtual Devices (AVDs) are emulators that allow you to test your application without the real device. You can create AVDs for different android platforms (from Android 1.x to Android 4.x) and configurations (e.g., phone/pad, screen size, orientation, SD card and its capacity).

  1. From Eclipse's "Window" menu ⇒ Preferences ⇒ Android ⇒ In "SDK Location", check and confirm it contains your Android's SDK installed directory.
  2. Start the AVD Manager: From Eclipse's "Window" menu ⇒ Select "AVD Manager". (You could also start the AVD manager by running "AVD Manager.exe" under the "sdk\tools\lib".)
  3. The "Android Virtual Device Manager" dialog appears ⇒ "New".
  4. The "Create New Android Virtual Device (AVD)" dialog appears.
    1. In "Name", enter "Android44_qvga".
    2. In "Device", select "2.7 QVGA" (try the smallest device first).
    3. In "Target", select "Android 4.4 - API Level 19".
    4. Set "SD Card Size" to 10 MB (do not set a huge SD Card size, which would take hours to create.) ⇒ OK.

Notes: For windows, the AVD is saved in "c:\Users\<user>\.android\avd\<avd-profile-name>.avd". The AVD location is shown in AVD manager on top of the table.

Step 2b: Launch Emulator (or AVD)

You can test your AVD created in the previous step by launching the emulator.

Start the AVD Manager: From Eclipse's "Window" menu ⇒ run "AVD Manager" ⇒ Select a AVD (e.g., "Android44_qvga") ⇒ Click the "Start" button ⇒ The "Launch Options" dialog appears ⇒ Launch.

WAIT patiently! The emulator is VERY SLOW and takes a few MINUTES to launch. Wait for the "Android" logo to appears and disappear. If a lock appears, unlock the screen by dragging the lock to the right.

You can change the orientation (between portrait and landscape) of the the emulator via "ctrl-F11".

We typically create different AVDs to emulate different real devices, e.g., Android44_xga of resolution (1024x768 XGA).

DO NOT CLOSE the emulator. Just leave it running. It takes time to re-start the emulator!!!

Step 3: Run the Android App

Before running the Android app, turn on the "Error Log" and "Progress" views: From "Window" ⇒ "Show View" ⇒ "Error Log". Repeat for "Progress" view.

Now, run the application by right-click on the "HelloAndroid" PROJECT NODE ⇒ "Run As" ⇒ "Android Application".

Be patient! It takes a few MINUTES to fire up the emulator (if the emulator has not been started)! Watch the "Progress" (for launch progess), Android's "Console" (for messages), and "Error Log" (for error messages).

[2014-03-20 18:20:26 - HelloAndroid] ------------------------------
[2014-03-20 18:20:26 - HelloAndroid] Android Launch!
[2014-03-20 18:20:26 - HelloAndroid] adb is running normally.
[2014-03-20 18:20:26 - HelloAndroid] Performing com.example.helloandroid.MainActivity activity launch
[2014-03-20 18:20:26 - HelloAndroid] Automatic Target Mode: using existing emulator 'emulator-5554'
                                     running compatible AVD 'Android44_phone'
[2014-03-20 18:20:26 - HelloAndroid] Uploading HelloAndroid.apk onto device 'emulator-5554'
[2014-03-20 18:20:30 - HelloAndroid] Installing HelloAndroid.apk...
[2014-03-20 18:20:39 - HelloAndroid] Success!
[2014-03-20 18:20:40 - HelloAndroid] Starting activity com.example.helloandroid.MainActivity on device emulator-5554
[2014-03-20 18:20:42 - HelloAndroid] ActivityManager: Starting: Intent { act=android.intent.action.MAIN
                                     cat=[android.intent.category.LAUNCHER] cmp=com.example.helloandroid/.MainActivity }

Once the emulator started, unlock the device by holding and sweeping the "lock" to the right (or left). It shall launch your Hello-world app, and displays "hello, world" on the screen with a title "Hello Android".

If your program is not launched automatically, try launching it from the "app menu" manually, after the emulator is started. Look for the icon marked "Hello Android".

Hello World

Trying launching the app from "HOME" ⇒ "..." ⇒ Look for the icon "Hello Android".

Also try "HOME" ⇒ "..." ⇒ "MENU" ⇒ "Manage Apps" ⇒ Select "HelloAndroid" ⇒ Un-install.

NOTE: DO NOT CLOSE the emulator, as it really takes a long time to start. You could always re-run or run new applications on the same emulator.

Step 5: Run the Android App on Real Devices

To run the Android app on a real device (Android Phone or Android Pad):

  1. Connect the real device to your computer. Make sure that you have the "USB Driver" for your device installed on your computer. You can find the "Google USB Driver" @ http://developer.android.com/sdk/win-usb.html, and Google's certified "OEM USB Drivers" @ http://developer.android.com/tools/extras/oem-usb.html. If you device is not certified there, good luck! It took me many hours to find a compatible driver for my cheap Android Pad.
  2. Enable "USB Debugging" mode on your real device: from "Settings" ⇒ "Applications" ⇒ "Development" ⇒ Check "USB Debugging". This allows Android SDK to transfer data between your computer and your device.
    Also enable "Unknown source" from "Applications". This allows applications from unknown sources to be installed on the device.
  3. You shall see the message "USB Debugging Connected" when you plugs the USB cable into your computer.
  4. From Eclipse, right-click on the project node ⇒ Run As ⇒ Android Application.
  5. The "Android Device Chooser" dialog appears. Select your real device (instead of the AVD emulator) ⇒ OK.
  6. Eclipse ADT installs the app on the connected device and starts it.
  7. You can unplug the device. The app has been installed. You can un-install the app via "Manage Apps".

(Advanced) Alternatively, you can also use the "adb" (Android Debug Bridge) tool (under "sdk\platform-tools") to install the ".apk" file ("HelloAndroid.apk") onto the real devices. The "sdk\platform-tools" directory must be included in the PATH.

// Change directory to <project-root>\bin, where the ".apk" is located
// -d option for real device
> adb -d install filename.apk
2402 KB/s (157468 bytes in 0.064s)
        pkg: /data/local/tmp/filename.apk
Success
  
> adb --help

Hello-world by Coding

Let's continue from the previous example.

Expand the "src" node. Expand the "com.example.helloandroid" package node. Open the "MainActivity.java", and replace it with the following codes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package com.example.helloandroid;
 
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
 
public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView textView = new TextView(this);   // Construct a TextView UI component
        textView.setText("Hello, from my code!"); // Set the text message for TextView
        setContentView(textView);  // this Activity sets its content to the TextView
    }
}

Run the application by right-clicking the project node ⇒ "Run As" ⇒ "Android Application". You shall see the message "Hello, from my code!".

Dissecting the "MainActivity.java" - Application, Activity & View

An Android application could have one or more Activity.

An Activity, which usually has a screen, is a single, focused thing that the user can interact with the application (hence called activity). The MainActivity extends the android.app.Activity class, and overrides the onCreate() method. The onCreate() is a call-back method, which is called by the Android system when the activity is launched.

A View is a UI component (or widget, or control). We construct a TextView (which is a subclass of android.view.View), and set its text message. We then set the content-view of the MainActivity screen to this TextView.

Android Application Structure

An Android project consists of these folders:

  • src: Java Source codes. The Java classes must be kept in a proper package with at least two levels of identifiers (by default, com.example.projectname for test project).
  • res: Resources, including drawable (e.g., images and icons), layout (UI components and layout), values (e.g., locale strings).
  • asset: where you store raw files (e.g., configuration, audio and image files).
  • gen: Generated Java codes.
  • bin: Compiled bytecodes (in sub-directory classes), and the ".apk" (Android Package Archive file).
  • AndroidManifest.xml: The manifest to describe this app, such as its activities and services.
  • default.properties: holds various settings for the build system, updated by the ADT.
  • Android 4.4: the build target platform, with link to Android API ("android.jar").
Android Application Descriptor File - "AndroidManifest.xml"

Each Android application has a manifest file named AndroidManifest.xml in the project's root directory. It describes the application.

For example, our "HelloAndroid" application, with an activity MainActivity, has the following manifest (generated automatically by the Eclipse ADT):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloandroid"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
 
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.helloandroid.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
  • The <manifest> element specifies the package name, version-code and version-name. The version-code is an integer uses by the Android Market to keep track of new versions, which is usually a running number starts at 1. The version-name is a string for your own identification.
  • The <manifest> contains one <application> element.
  • The <application> element specifies the icon, label (the application's title) and theme of this application. It contains one ore more <activity> elements.
  • This application has one activity. The <activity> element declares its program name ("MainActivity" in package com.example.helloandroid); and label (the activity's screen title). It may contain <intent-filter>.
  • The <intent-filter> declares that this activity is the entry point (android.intent.action.MAIN) of the application. This activity is to be added to the application launcher (android.intent.category.LAUNCHER).

Hello-world using XML Layout

Instead of writing Java codes to create the user interface (UI). It is more flexible and therefore recommended to layout your UI components via a descriptive XML layout file. In this way, you don't need to hardcode the views, and you can easily modify the look and feel of the application by editing the XML markups. The Java codes can therefore focus on the business logic. (This is similar to the Model-View-Control (MVC) framework used in web applications where the views are written in JSPs using markups and the controls in Servlets, which are clearly separated. This is also similar to client-side programming where HTML is used for contents, CSS for presentation and JavaScript for programming logic. Again, views, contents and programs are clearly separated).

To improve the performance, the XML files are compiled into binary using the Android Asset Packaging Tool (aapt). The devices store them as binary, and the file is read in binary, instead of converting back to XML, for efficiency.

Let's rewrite our hello-world to use XML layout.

Step 1: Create a New Android Application

Create a new Android application called "HelloAndroidXML", with project name "HelloAndroidXML" and package name "com.example.helloandroidxml". Create a "BlankActivity" called "MainActivity", with layout "activity_main".

Step 2: Define the Layout in XML - "res\layout\activity_main.xml"

Expand the "HelloAndroidXML" project node. Further expand the "res" node and "layout" node. Open the "activity_main.xml". Eclipse provides two views for this XML file: "Graphics Layout" and "XML". Click the "activity_main.xml" tab (at the bottom of the panel) and study the XML code:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
 
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />
 
</RelativeLayout>

The activity_main.xml file declares a TextView that holds a text string. Instead of hardcoding the string content, a string reference called @string/hello_world is used, with the actual string coded in res/values/strings.xml. This approach is particular useful to support internationalization (i18n), as you can customize different strings for different locales (e.g, English/French/Chinese).

This activity's uses a "relative-layout", where its components are arranged relative to each other. It has width and height matching its parent ("match_parent").

The screen contains a TextView component, with its text obtained from the string reference "@string/hello_world". The TextView component has width and height big enough to hold its content ("wrap_content").

Step 3: Defining String References and Values - "res\values\string.xml"

Expand res/values node. Open strings.xml, and study the XML codes (click on string.xml view):

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Hello Android XML</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>
</resources>

This "string.xml" defines these string references and values:

  • A string reference "hello_world" contains value of "Hello world!". Change the value to "Hello, from XML!".
  • A string reference "app_name" contains the application's name, that you entered when you created the project. This reference is used in "AndroidManifest.xml" (to be described later).
Step 4: The Activity - "MainActivity.java"

Next, study the "MainActitivy.java" (right-click on the project ⇒ Expand "src" node ⇒ Expand package node "com.example.helloandroidxml"), as follows:

package com.example.helloandroidxml;
 
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
 
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}

The "MainActivity" sets its content-view to "R.layout.activity_main", which is mapped to the XML layout file "res\layout\activity_main.xml" that we have studied earlier.

Step 5: Run the App

Run the application (right-click the project node ⇒ "Run As" ⇒ "Android Application"). You shall see the new string "Hello, from XML!" displayed on the emulator.

Step 6: The Generated Resource Reference Class - "gen\R.java"

The Eclipse ADT automatically generates a "R.java", which keeps track of all the application resources, in "gen" directory as follows:

package com.example.helloandroidxml;
 
public final class R {
    public static final class attr {
    }
    public static final class dimen {
        public static final int activity_horizontal_margin=0x7f040000;
        public static final int activity_vertical_margin=0x7f040001;
    }
    public static final class drawable {
        public static final int ic_launcher=0x7f020000;
    }
    public static final class id {
        public static final int action_settings=0x7f080000;
    }
    public static final class layout {
        public static final int activity_main=0x7f030000;
    }
    public static final class menu {
        public static final int main=0x7f070000;
    }
    public static final class string {
        public static final int action_settings=0x7f050001;
        public static final int app_name=0x7f050000;
        public static final int hello_world=0x7f050002;
    }
    public static final class style {
        public static final int AppBaseTheme=0x7f060000;
        public static final int AppTheme=0x7f060001;
    }
}

The R.java ("R" stands for resources) indexes all the resources used in this application in the static nested classes such as layout and string. For example, the inner class layout's property activity_main (R.layout.activity_main) references res\layout\activity_main.xml; the inner class string (R.string) references res\values\strings.xml.

Problems with ADT

These may help:

  1. Do not unzip Android Bundle under the "Program Files" or an directory name with spaces. The space in the directory file may cause problem.
  2. Update the ADT by selecting "Help" ⇒ Install New Software ⇒ In "Work With", type https://dl-ssl.google.com/android/eclipse/ ⇒ Select ALL ⇒ Next ⇒ Next ⇒ Accept the license agreement ⇒ Finish. Subsequently, update the SDK as per screen instruction ⇒ "Install x packages".
  3. Re-start eclipse with "clean" option (in cmd or terminal, run "eclipse -clean") and create a new directory for the workspace.
  4. Error in Android Project: Close the project. Re-open the project and refresh (F5).
  5. Cannot start emulator: You can start the emulator from the command-line via command "emulator -avd avdName" and WAIT, where emulator.exe is lcoated at "sdk\tools".
  6. Cannot start emulator: Delete the AVD and re-create an AVD.
  7. Cannot start emulator: Goto "sdk\tools" ⇒ right-click on "emulator.exe" ⇒ Check "Run this program in compatibility" ⇒ Windows XP SP 3.
  8. Starting from ADT 22.6, an Eclipse project called "appcompat_v7" will be created automatically if your "minimum required SDK" is API 13 and below, which provides supports for backward compatibility. To avoid this, set your "minimum required SDK" to API 14.
  9. Starting from ADT 22.6, a fragment layout name "fragment_main" is created automatically, under the "activity_main". To disable this, uncheck "Create Activity" in "Create Activity" dialog. Create the activity (and layout) yourself and add the activity to the manifest. [The "appcompat_v7" project also not created.]

(Skip) Publishing Your App

To publish your apps on Android Maket/Google Play, you need to sign your app with your digital certificate. (During development, you app is signed using a debug certificate by the Eclipse ADT.)

Signing Android Apps
  1. From Eclipse, right-click on the project ⇒ Export... ⇒ Android ⇒ Export Android Application.
  2. In "Project Checks" dialog ⇒ Next.
  3. In "Keystore selection" ⇒ Create new keystore ⇒ In "Location", enter the filename for the keystore (e.g., keystore.db) ⇒ Set your password for the keystore.
  4. In "Key creation", enter the data ⇒ Finish.

References:

  1. Signing Your Applications @ http://developer.android.com/tools/publishing/app-signing.html.
  2. For keystore management, read JDK documentation on "keytool - Key and Certificate Management Tool".

(Skip) Using Android Debug Bridge (ADB)

ADB lets you manage the connected real devices and emulator AVDs. ADB actually consists of three parts:

  • A client program called "adb.exe" (kept under the "<ANDROID_SDK_HOME>\platform-tools").
  • A server that that runs on your development machine, which is responsible for communicating between an "adb" client program and the connected real devices or emulator AVDs.
  • The ADB daemon, which runs as a background process on every real device and emulator AVD. The ADB server connects to this daemon for communication.

You can use the "adb" client to install Android apps (in ".apk" format), or copy files between your development machine and real device's internal storage and external SD card.

From a CMD shell, launch the "adb" client program (you need to include the "<ANDROID_SDK_HOME>\platform-tools" in the PATH):

// List the command options
> adb --help
......
 
// List all the devices connected, take note of the device serial number
> adb devices
......
 
// Install app in the device of the given serial number
> adb –s device_id install app_filename.apk
// Install app on real device
> adb -d install app_filename.apk
// Install app on emulator
> adb -e install app_filename.apk
 
// Copy the file from the development machine to the device
> adb push computer_filename sdcard_filename
// Copy the file from the device to development machine
> adb pull sdcard_filename computer_filename

Next?

Continue with the "Android Training" @ http://developer.android.com/training/index.html.

Read the Android "API Guides" @ http://developer.android.com/guide/components/index.html.

Study the Android sample codes (in Android SDK "samples" directory), especially the "API Demos".

To run the sample programs in Eclipse: Select "File" menu ⇒ "New" ⇒ "Project..." ⇒ "Android" ⇒ "Android Sample Project" ⇒ E.g., "API Demos".

To import an existing project:

  1. Select "File" menu ⇒ "New" ⇒ "Project..." ⇒ "Android" ⇒ "Android Project from Existing Code" ⇒ Next.
  2. In "Import Project" dialog, browse and select the desired project from the Android SDK's "samples" (e.g., "ApiDemos"). Check "Copy projects into workspace".
  3. Run the application. Right-click on the project ⇒ "Run As" ⇒ "Android Application".

REFERENCES & RESOURCES

  1. Android SDK @ http://developer.android.com/sdk/index.html.
  2. "Android Training" @ http://developer.android.com/training/index.html.
  3. Android "API Guides" @ http://developer.android.com/guide/components/index.html.
Link to Android's References and Resources