ANDORID PROGRAMMING COMMAND LINE SAMPLE BASIC INFORMATION



Here is a sample command that creates an Android project from the command line:

android create project --target "Google Inc.:Google APIs:7" --path Skeleton/Now
--activity Now --package com.commonsware.android.skeleton

This will create an application skeleton for you, complete with everything you need to build your first Android application: Java source code, build instructions, etc. However, you are probably going to need to customize this somewhat.

Here are what those command-line switches mean:

• --target indicates what version of Android you are "targeting" in terms of your build process.
You need to supply the ID of a target that is installed on your development machine, one you downloaded via the SDK and A VD Manager.

You can find out what targets are available via the android list targets command. T ypically, your build process will target the newest version of Android that you have available.

• --path indicates where you want the project files to be generated.
Android will create a directory if the one you name does not exist. For example, in the command shown above, a Skeleton/Now/ directory will be created (or used if it exists) underneath the current working directory, and the project files will be stored there.

• --activity indicates the Java class name of your first activity for this project.
Do not include a package name, and the name has to meet Java class naming conventions.

• --package indicates the Java package in which your first activity will be located.
This package also uniquely identifies your project on any device on which you install it, and this package also needs to be unique on the Android Market if you plan on distributing your application there.

Hence, typically, you construct your package based on a domain name you own (e.g., com.commonsware.android.skeleton), to reduce the odds of an accidental package name collision with somebody else.

For your development machine, you will need to pick a suitable target, and you may wish to change the path. The activity and package you can leave alone for now.

No comments:

Post a Comment