Thursday, October 20, 2011

Creating Android Projects

Brief History
Android is the first complete, open, and free mobile platform. Developers enjoy a comprehensive software development kit, with ample tools for developing powerful, feature- rich applications. 
The platform is open source, relying on tried-and-true open standards developers will be familiar with. And best of all, there are no costly barriers to entry for developers: no required fees. (A modest fee is required to publish on thirdparty distribution mechanisms such as the Android Market.) Android developers have numerous options for distributing and commercializing their applications.


Creating Android "Hello World" App.
Before u start creating Android Projects you should already have the Java (JDK 5 or JDK 6) installed + Eclipse ( >= 3.5 (Galileo)) + Android SDK + ADT Plugin.

The Android Project Wizard creates all the required files for an Android application.
Open Eclipse and follow these steps to create a new project:
  1. Choose File, New, Android Project or click the Android Project creator icon on the Eclipse toolbar.
  2. Choose a project name. In this case, name the project HelloVasif.
  3. Choose a location for the project source code. Because this is a new project, select the Create New Project in Workspace radio button.
  4. Select a build target for your application. For most applications, you want to select the version of Android most appropriate for the devices used by your target audience and the needs of your application. If you are planning to use the Google add-ons (for example, Google Maps), be sure to choose the Google APIs version for your target platform. For this example, the Android 2.3 (API level 9) build target is sufficient.
  5. Specify an application name. This name is what users will see. In this case, call the application HelloVasif#1
  6. Specify a package name, following standard package namespace conventions for Java. Because all code in this book falls under the com.androidbook.* namespace, use the package name com.blogspot.vmustafayev4en.
  7. Click the Finish button.
In eclipse Package Explorer Open <project>/res/values/strings.xml file and edit the string resource called @string/hello


Debugging Applications
To build and debug an Android application, you must first configure your project for
debugging.
  1. Launch the Android SDK and AVD Manager from within Eclipse by clicking the little green Android icon with the arrow  on the toolbar. You can also launch the manager by selecting Window, Android SDK and AVD Manager in Eclipse.
  2. Click the Virtual Devices menu item on the left menu. The configured AVDs will be displayed as a list. There are no default AVDs
  3. Click the New button to create a new AVD.
  4. Choose a name for the AVD. Because you are going to take all the defaults,name this AVD VanillaAVD.
  5. Choose a build target. For example, to support Android 2.3, choose the item build target called Android 2.3 – API Level 9 from the drop-down.
  6. Choose an SD card capacity, in either kibibytes or mibibytes, such as  a 1024MiB. (The minimum is 9MiB, but keep in mind that the full size of the SD card is stored on your machine.)
  7. Click Finish. You should now see your newly created AVD in the list.

You are almost ready to launch your application. You have one last task remaining: You need to create a Debug configuration (or a Run configuration) for your project in Eclipse. To do this, take the following steps:

  1. In Eclipse, choose Run, Debug Configurations from the menu, or, alternatively, click the drop down menu next to the Debug icon on the Eclipse toolbar and choose the Debug Configurations option.
  2. Double-click the Android Application item to create a new entry.
  3. Edit that new entry, currently called New_configuration.
  4. Change the name of the configuration to HelloVasifsDebug.
  5. Set the project by clicking the Browse button and choosing the HelloVasif1 project.
  6. On the Target tab, check the box next to the AVD you created.
  7. Apply your changes by clicking the Apply button.
It’s launch time, and your application is ready to go! To launch the application, you can simply click the Debug button from within the Launch Configuration screen, or you can do it from the project by clicking the little green bug icon on the Eclipse toolbar. Then select HelloVasifsDebug debug configuration from the list.

After you click the Debug button, the emulator launches, as shown above This can take some time, so be patient :)

Congratulations! You are now an Android developer. You have begun to learn your way around the Eclipse development environment. You created your first Android project. You reviewed and compiled working Android code. Finally, you ran your newly created Android application on the Android emulator as well as on a real Android device.

No comments:

Post a Comment