Note: Check the parent post here.
The first step is to create a Project. Projects are the repositories for the application’s source code, resource files, and other files necessary to build the application. There are three types of projects -
Android Projects – apart from storing the application’s source code and resource files, an Android project also contains the Ant build file and the Android Manifest file. This is the main application project and the contents from these are eventually built into a .apk file that is installed on the device or the emulator.
Test Projects – these contain code to test the application projects and can be installed on a device/emulator.
Library Projects – these contain the common utilities/source code and resources that need to be shared or referenced by the Android projects. These can be invoked at run time into the .apk file, but cannot be installed on a device/emulator.
For our purpose, we need to create an Android Project.
Step 1: Creating a Project without Eclipse
The command to create a project is:
android create project \
--path path/to/your/project \
target_ID = target ID obtained from android list targets. Select the one
that contains the add-on Google APIs for your version of the Android SDK
name = name for your project e.g. MyAndroidApp
path = path where you want the application directories/files to be created
activity = name for your default Activity class, which is created in
package = package namespace for the project
$ android create project \
--target 4 \
--name MyAndroidApp \
--path $HOME_DIR/android/MyAndroidAppProject \
--activity MyAndroidActivity \
creates the directories and files in the specified project directory, in this case $HOME_DIR/android/MyAndroidAppProject
Step 2: Creating the Hello World application
To create our first Android Application viz. the Hello World application, we will need to modify the code. Navigate to the src directory of the project. Edit the MyAndroidActivity.java file and make the changes as shown –