You need to install the Android SDK and developer tools.Once you have the Android SDK, it istime to make your first Android project. The good news is that this requires zero lines of code – Android's tools create a "Hello, world!" application for you as part of creating a new project. All you need to do is build it, install it, and see it come up on your emulator or device.
Step #1: Create the New Project
Android's tools can create a complete skeleton project for you, with everything you need for a complete Android application.
Step #1: Eclipse
From the Eclipse main menu, choose File | New | Project..., and this will bring up a list of project types to choose from. Fold open the Android
option and click on Android Project:
Press Next to advance the wizard to the main Android project page:
Fill in the following:
• The name of the project (e.g., Now)
• The Android SDK you wish to compile against (e.g., Google APIs for
Android 2.3)
• The name of the Java package in which this project goes (e.g.,com.commonsware.android.skeleton)
• The name of the initial activity to create (e.g., Now)
At this point, clicking Finish will create your Eclipse project.
Step #2: Build, Install, and Run the Application in Your Emulator or Device
Having a project is nice and all, but it would be even better if we could build and run it, whether on the Android emulator or your Android device.
Once again, the process differs somewhat depending on whether you are using Eclipse or not.
Step #1: Eclipse
With your project selected in the Package Explorer pane, click the green "play" button in the Eclipse toolbar to run your project. The first time you
do this, you will have to go through a few steps to set up a "run configuration", so Eclipse knows what you want to do. First, in the "Run As" list, choose "Android Application":
If you have more than one emulator A VD or device available, you will then get an option to choose which you wish to run the application on.
Otherwise, if you do not have a device plugged in, the emulator will start up with the A VD you created earlier. Then, Eclipse will install the application on your device or emulator and start it up.
Notice there is an icon for your Now application. Click on it to open it and see your first activity in action. T o leave the application and return to the launcher, press the "BACK button", located to the right of the [MENU] button, and looks like an arrow pointing to the left.
Comments
Post a Comment