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 plugininstalled (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
- Click New in the toolbar.
- In the window that appears, open the Android folder, select Android Application Project, and click Next.
Figure 1. The New Android App Project wizard in Eclipse.
- Fill in the form that appears:
Click Next.
- 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.
- 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.
--path <path-to-workspace>/MyFirstApp --activity MainActivity \ --package com.example.myfirstapp