Android Training
This lesson teaches you to
You should also read
An Android project contains all the files that comprise the source code for your Android app. The Android SDK tools make it easy to start a new Android project with a set of default project directories and files.
This lesson shows how to create a new project either using Eclipse (with the ADT plugin) or using the SDK tools from a command line.
Note: You should already have the Android SDK installed, and if you're using Eclipse, you should also have the ADT plugin installed (version 21.0.0 or higher). If you don't have these, follow the guide to Installing the Android SDK before you start this lesson.
Create a Project with Eclipse
Figure 1. The New Android App Project wizard in Eclipse.
-
Click New
in the toolbar.
- In the window that appears, open the Android folder, select Android Application Project, and click Next.
-
Fill in the form that appears:
-
Application Name is the app name that appears to users. For this project, use "My First App."
- Project Name is the name of your project directory and the name visible in Eclipse.
- Package Name is the package namespace for your app (following the same rules as packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. For this reason, it's generally best if you use a name that begins with the reverse domain name of your organization or publisher entity. For this project, you can use something like "com.example.myfirstapp." However, you cannot publish your app on Google Play using the "com.example" namespace.
- Minimum Required SDK is the lowest version of Android that your app supports, indicated using the API level. To support as many devices as possible, you should set this to the lowest version available that allows your app to provide its core feature set. If any feature of your app is possible only on newer versions of Android and it's not critical to the app's core feature set, you can enable the feature only when running on the versions that support it (as discussed in Supporting Different Platform Versions). Leave this set to the default value for this project.
-
Target SDK indicates the highest version of Android (also using the API level) with which you have tested with your application.
As new versions of Android become available, you should test your app on the new version and update this value to match the latest API level in order to take advantage of new platform features.
- Compile With is the platform version against which you will compile your app. By default, this is set to the latest version of Android available in your SDK. (It should be Android 4.1 or greater; if you don't have such a version available, you must install one using the SDK Manager). You can still build your app to support older versions, but setting the build target to the latest version allows you to enable new features and optimize your app for a great user experience on the latest devices.
- Theme specifies the Android UI style to apply for your app. You can leave this alone.
Click Next.
-
Application Name is the app name that appears to users. For this project, use "My First App."
- On the next screen to configure the project, leave the default selections and click Next.
-
The next screen can help you create a launcher icon for your app.
You can customize an icon in several ways and the tool generates an icon for all screen densities. Before you publish your app, you should be sure your icon meets the specifications defined in the Iconography design guide.
Click Next.
-
Now you can select an activity template from which to begin building your app.
For this project, select BlankActivity and click Next.
- Leave all the details for the activity in their default state and click Finish.
Your Android project is now set up with some default files and you’re ready to begin building the app. Continue to the next lesson.
Create a Project with Command Line Tools
If you're not using the Eclipse IDE with the ADT plugin, you can instead create your project using the SDK tools from a command line:
-
Change directories into the Android SDK’s
tools/path. -
Execute:
android list targets
This prints a list of the available Android platforms that you’ve downloaded for your SDK. Find the platform against which you want to compile your app. Make a note of the target id. We recommend that you select the highest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to optimize your app for the latest devices.
If you don't see any targets listed, you need to install some using the Android SDK Manager tool. See Adding Platforms and Packages.
-
Execute:
android create project --target <target-id> --name MyFirstApp \ --path <path-to-workspace>/MyFirstApp --activity MainActivity \ --package com.example.myfirstapp
Replace
<target-id>with an id from the list of targets (from the previous step) and replace<path-to-workspace>with the location in which you want to save your Android projects.
Your Android project is now set up with several default configurations and you’re ready to begin building the app. Continue to the next lesson.
Tip: Add the platform-tools/ as well as the tools/ directory to your PATH environment variable.
Installing the Eclipse Plugin
Android offers a custom plugin for the Eclipse IDE, called Android Development Tools (ADT). This plugin provides a powerful, integrated environment in which to develop Android apps. It extends the capabilities of Eclipse to let you quickly set up new Android projects, build an app UI, debug your app, and export signed (or unsigned) app packages (APKs) for distribution.
If you need to install Eclipse, you can download it from eclipse.org/mobile.
Note: If you prefer to work in a different IDE, you do not need to install Eclipse or ADT. Instead, you can directly use the SDK tools to build and debug your application.
Download the ADT Plugin
- Start Eclipse, then select Help > Install New Software.
- Click Add, in the top-right corner.
-
In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
https://dl-ssl.google.com/android/eclipse/
-
Click OK.
If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
- In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
- In the next window, you'll see a list of the tools to be downloaded. Click Next.
-
Read and accept the license agreements, then click Finish.
If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
- When the installation completes, restart Eclipse.
Configure the ADT Plugin
Once Eclipse restarts, you must specify the location of your Android SDK directory:
- In the "Welcome to Android Development" window that appears, select Use existing SDKs.
- Browse and select the location of the Android SDK directory you recently downloaded and unpacked.
- Click Next.
Your Eclipse IDE is now set up to develop Android apps, but you need to add the latest SDK platform tools and an Android platform to your environment. To get these packages for your SDK, continue to Adding Platforms and Packages.
Troubleshooting Installation
If you are having trouble downloading the ADT plugin after following the steps above, here are some suggestions:
-
If Eclipse can not find the remote update site containing the ADT plugin, try changing the remote site URL to use http, rather than https. That is, set the Location for the remote site to:
http://dl-ssl.google.com/android/eclipse/
- If you are behind a firewall (such as a corporate firewall), make sure that you have properly configured your proxy settings in Eclipse. In Eclipse, you can configure proxy information from the main Eclipse menu in Window (on Mac OS X, Eclipse) > Preferences > General > Network Connections.
If you are still unable to use Eclipse to download the ADT plugin as a remote update site, you can download the ADT zip file to your local machine and manually install it:
-
Download the ADT Plugin zip file (do not unpack it):
Package Size MD5 Checksum ADT-21.1.0.zip 13564671 bytes f1ae183891229784bb9c33bcc9c5ef1e - Start Eclipse, then select Help > Install New Software.
- Click Add, in the top-right corner.
- In the Add Repository dialog, click Archive.
- Select the downloaded ADT-21.1.0.zip file and click OK.
- Enter "ADT Plugin" for the name and click OK.
- In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
- In the next window, you'll see a list of the tools to be downloaded. Click Next.
-
Read and accept the license agreements, then click Finish.
If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
- When the installation completes, restart Eclipse.
To update your plugin once you've installed using the zip file, you will have to follow these steps again instead of the default update instructions.
Other install errors
Note that there are features of ADT that require some optional Eclipse packages (for example, WST). If you encounter an error when installing ADT, your Eclipse installion might not include these packages. For information about how to quickly add the necessary packages to your Eclipse installation, see the troubleshooting topic ADT Installation Error: "requires plug-in org.eclipse.wst.sse.ui".
For Linux users
If you encounter this error when installing the ADT Plugin for Eclipse:
An error occurred during provisioning. Cannot connect to keystore. JKS
…then your development machine lacks a suitable Java VM. Installing Sun Java 6 will resolve this issue and you can then reinstall the ADT Plugin.
Adding Platforms and Packages
The Android SDK separates tools, platforms, and other components into packages you can download using the Android SDK Manager. The original SDK package you've downloaded includes only the SDK Tools. To develop an Android app, you also need to download at least one Android platform and the latest SDK Platform-tools.
-
Launch the SDK Manager.
If you've used the Windows installer to install the SDK tools, you should already have the Android SDK Manager open. Otherwise, you can launch the Android SDK Manager in one of the following ways:
-
On Windows, double-click the
SDK Manager.exefile at the root of the Android SDK directory. -
On Mac or Linux, open a terminal and navigate to the
tools/directory in the Android SDK, then executeandroid sdk.
-
On Windows, double-click the
-
The SDK Manager shows all the SDK packages available for you to add to your Android SDK. As a minimum configuration for your SDK, we recommend you install the following:
- The latest Tools packages (check the Tools folder).
- The latest version of Android (check the first Android folder).
- The Android Support Library (open the Extras folder and check Android Support Library).
Once you've chosen your packages, click Install. The Android SDK Manager installs the selected packages into your Android SDK environment.
With these packages installed, you're ready to start developing. To get started, read Building Your First App.

Figure 1. The Android SDK Manager shows the SDK packages that are available, already installed, or for which an update is available.
Additional information
- For more information about using the SDK Manager and some of the available packages, see the SDK Manager document.
- This web site provides all information you need to develop Android apps, including design guidelines, developer training, API reference, and information about how you can distribute your app. We recommend you begin by reading Building Your First App.
- For additional resources about developing and distributing your app, see the Developer Support Resources.







