Friday, 11 May 2012

hOW TO Create an new Android Project

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.

    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).
    Open the Android folder, select Android Project and click Next.
    Enter a project name (such as "MyFirstApp") and click Next.
    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.
    Specify other app details, such as the:
        Application Name: The app name that appears to the user. Enter "My First App".
        Package Name: The package namespace for your app (following the same rules as packages in the Java programming language). Your package name must be unique across all packages installed on the Android system. For this reason, it's important that you use a standard domain-style package name that’s appropriate to your company or publisher entity. For your first app, you can use something like "com.example.myapp." However, you cannot publish your app using the "com.example" namespace.
        Create Activity: This is the class name for the primary user activity in your app (an activity represents a single screen in your app). Enter "MyFirstActivity".
        Minimum SDK: Select 4 (Android 1.6).

        Because this version is lower than the build target selected for the app, a warning appears, but that's alright. You simply need to be sure that you don't use any APIs that require an API level greater than the minimum SDK version without first using some code to verify the device's system version (you'll see this in some other classes).

    Click Finish.

Your Android project is now set up with some default files and you’re ready to begin building the app

No comments:

Post a Comment