Here’s our first of many tutorial about how to code in Android. To start, it’s important to know how to create a simple project in Eclipse (a tool that we will use in our tutorials).
Step 1: Create a New Project
Eclipse is a powerful, open source, integrated development environment (IDE) that facilitates the creation of desktop, mobile, and web applications. Eclipse is a highly versatile and adaptable tool.
Android is a mobile operating system designed for smartphones and tablets. The operating system is very powerful, enabling access to a diverse set of hardware resources on a smartphone or tablet. Android is provided by Google and is continually updated, improved, and extended. This makes the development of apps for Android smartphones and tablets both exciting and challenging. As with Eclipse, the many features of the Android environment are best explained through the act of developing an app.
Step 2: Select Form Factors and API Level
The API Level window shows the distribution of mobile devices running each version of Android, Click on an API level to see a list of features introduced in the corresponding version of Android. This helps you choose the minimum API Level that has all the features that your apps needs, so you can reach as many devices as possible. Then click OK.
Step 3: Add an Activity
Choose an activity type and click Next.
Step 4: Configure Your Activity
Enter the activity name, the layout name, and the activity title. Then click Finish.
Your basic Android project is ready with some default files!
But wait, before you run your app, let’s discuss about some of the important directories and files in the Android project:
- AndroidManifest.xml – The manifest file describes the fundamental characteristics of the app and defines each of its components.
- One of the most important elements your manifest should include is the <uses-sdk> element. This declares your app’s compatibility with different Android versions using the android:minSdkVersion andandroid:targetSdkVersion attributes. For your first app, it should look like this.
Step 5: Develop Your App
Step 6: To launch your project make AVD(android virtural device)
The AVD Manager is an easy to use user interface to manage your AVD (Android Virtual Device) configurations.
To create an AVD:
- Start the AVD Manager:
- In Eclipse: select Window > AVD Manager, or click the AVD Manager icon in the Eclipse toolbar.
- In other IDEs: Navigate to your SDK’s tools/ directory and execute the android tool with no arguments.
- In the Virtual Devices panel, you’ll see a list of existing AVDs. Click New to create a new AVD. The Create New AVD dialog appears.
To Run android Project there are two methods :
- Running on the emulator
To run (or debug) your application, select Run > Run (or Run > Debug) from the Eclipse menu bar. The ADT plugin will automatically create a default run configuration for the project. Eclipse will then perform the following
- Running on a device
Before you can run your application on a device, you must perform some basic setup for your device:
- Ensure that your application is debuggable by setting the android:debuggable attribute of the <application>element to true. As of ADT 8.0, this is done by default when you build in debug mode.
- Enable USB debugging on your device.
- On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.
- On Android 4.0 and newer, it’s in Settings > Developer options.
Congratulations!!! Your First android app is running