page.title=Creating an Android Project parent.title=Building Your First App parent.link=index.html trainingnavtop=true next.title=Running Your App next.link=running-app.html @jd:body

This lesson teaches you to

  1. Create a Project with Eclipse
  2. Create a Project with Command Line Tools

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 have installed the ADT plugin as well. If you have not installed these, see Installing the Android SDK and return here when you've completed the installation.

Create a Project with Eclipse

Figure 1. The new project wizard in Eclipse.

  1. In Eclipse, select File > New > Project. The resulting dialog should have a folder labeled Android. (If you don’t see the Android folder, then you have not installed the ADT plugin—see Installing the ADT Plugin).
  2. Open the Android folder, select Android Project and click Next.
  3. Enter a project name (such as "MyFirstApp") and click Next.
  4. Select a build target. This is the platform version against which you will compile your app.

    We recommend that you select the latest version possible. You can still build your app to support older versions, but setting the build target to the latest version allows you to easily optimize your app for a great user experience on the latest Android-powered devices.

    If you don't see any built targets listed, you need to install some using the Android SDK Manager tool. See step 4 in the installing guide.

    Click Next.

  5. Specify other app details, such as the:

    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 in a command line:

  1. Change directories into the Android SDK’s tools/ path.
  2. 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 step 4 in the installing guide.

  3. Execute:
    android create project --target <target-id> --name MyFirstApp \
    --path <path-to-workspace>/MyFirstApp --activity MyFirstActivity \
    --package com.example.myapp
    

    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.