Creating a new Project

If you're starting a new project, use the android create project command to generate all the necessary files and folders.

To create a new Android project, open a command-line, navigate to the tools/ directory of your SDK and run:

android create project \ --target <targetID> \ --path /path/to/your/project \ --activity <your_activity_name> \ --package <your_package_namespace>

• target is the "build target" for your application. It corresponds to an Android platform library (including any addons, such as Google APIs) that you would like to build your project against. To see a list of available targets and their corresponding IDs, execute: android list targets.

• path is the location of your project directory. If the directory does not exist, it will be created for you.

• activity is the name for your Activity class. This class file will be created for you inside


• package is the package namespace for your project, following the same rules as for packages in the Java programming language.

Here's an example:

android create project \ --target 1 \ --path ./myProject \ --activity MyActivity \ --package com.example.myproject

The tool generates the following files and directories:

AndroidManifest.xml - The application manifest file, synced to the specified Activity class for the project.

• - Properties for the build system. Do not modify this file.

• - Customizable properties for the build system. You can edit this file to overried default build settings used by Ant.

• src/your/package/namespace/ - The Activity class you specified during project creation.

• bin/ - Output directory for the build script.

• gen/ - Holds Ant-generated files, such as

• tests/ - Holds a duplicate of all-of-the-above, for testing purposes.

Once you've created your project, you're ready to begin development. You can move your project folder wherever you want for development, but keep in mind that you must use the Android Debug Bridge (adb) — located in the SDK tools/ directory — to send your application to the emulator (discussed later). So you need access between your project solution and the tools/ folder.

Note: You should refrain from moving the location of the SDK directory, because this will break the build scripts. (They will need to be manually updated to reflect the new SDK location before they will work again.)

0 0


    How to build a new andriod project?
    7 years ago

Post a comment