How to Create Your First Android Project

After you have Java Runtime Environment and Android Software Development Kit (SDK) installed on your development computer, you’re ready to start Eclipse and create a real, live Android app.

To create your first Android application, follow these steps:

  1. Launch Eclipse.

  2. From the main menu in Eclipse, choose File→New→Android Application Project.

    As a result, Eclipse fires up its New Android Application dialog box, as shown in the figure.

  3. In the Application Name field, type a name for the app.

    In the figure, type the boring words My First Android App. Ordinary folks such as Joe and Jane User, however, will see this name under the app’s icon on the Android launcher screen. If you’re planning to market your app, make the name short, sweet, and descriptive. You can even include blank spaces in the name.

    The next several steps involve lots of clicking, but you primarily accept the default settings.

    image0.jpg
  4. (Optional) In the Project Name and Package Name fields, change the name of the project and the name of the Java package containing the project.

    Eclipse automatically fills in the Project Name and Package Name fields (guided by whatever text you type in the Application Name field). In the figure, Eclipse creates the project name MyFirstAndroidApp and the package name com.example.myfirstandroidapp. Eclipse uses the project name to label this app’s branch in the Package Explorer tree.

    For practice apps, you can cheat by using the package name that Eclipse creates. But if you plan to publish an app, give the app its own package name.

    In Android, a package name belongs to only one app. You can put the first app in the package org.allyourcode.firstapp and put the second app in the package org.allyourcode.secondapp. But you can’t put more than one app in an org.allyourcode.mystuff package.

  5. (Optional) Choose values from the drop-down boxes in the dialog box.

    In the figure, the offered defaults were accepted — API 8, API 16, and API 17. You can select any values from the drop-down boxes as long as you’ve created an Android Virtual Device (AVD) that can run the target’s projects.

    (For example, an Android 2.3.3 AVD can run projects targeted to earlier versions of Android, such as Android 2.3.1, Android 2.2, and Android 1.6. The project target doesn’t have to be an exact match with an existing AVD.)

    If you mistakenly select a target for which you have no AVD, Eclipse hollers at you when you try to run the project. (Though Eclipse hollers, it also offers to help you create the necessary AVD, so everything turns out just fine.)

  6. Click Next.

    As a result, the New Android Application dialog box reappears. (See the figure — okay, originality in naming dialog boxes may not be Eclipse’s strong suit.)

    image1.jpg
  7. (Optional) Tweak the settings in the latest incarnation of the New Android Application dialog box.

    For a practice app, it’s a good idea to deselect the Create Custom Launcher Icon check box and leaving untouched the other settings in this New Android Application dialog box. In particular, keep the Create Activity option selected.

  8. Click Next.

    As a result, the Create Activity dialog box appears, as shown in the figure.

  9. Click Next again. (In other words, accept the defaults in the Create Activity dialog box.)

    image2.jpg

    The next box in the sequence is the New Blank Activity dialog box, as shown in this figure.

    image3.jpg
  10. Click Finish. (That is, accept the defaults.)

    As a result, the New Blank Activity dialog box closes, and the Eclipse workbench moves to the foreground. The Package Explorer tree in Eclipse has a new branch. The branch’s label is the name of the new project, as shown in the figure.

    image4.jpg

    Congratulations — you’ve created an Android application.

  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.