Dosto Kia hal hy umeed hy ap sub theek honge Aj me Android APK File Develop Krne Wale Topic ko Continue Karunga

Building Your First APP for Android

Running Your App


If you followed the previous lesson to create an Android project, it includes a default set of "Hello World" source files that allow you to immediately run the app.

How you run your app depends on two things: whether you have a real Android-powered device and whether you're using Eclipse. This lesson shows you how to install and run your app on a real device and on the Android emulator, and in both cases with either Eclipse or the command line tools.

Before you run your app, you should be aware of a few 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. You'll learn about various declarations in this file as you read more training classes.

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 and android:targetSdkVersion attributes. For your first app, it should look like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
...
</manifest>


You should always set the android:targetSdkVersion as high as possible and test your app on the corresponding platform version.

src/
Directory for your app's main source files. By default, it includes an Activity class that runs when your app is launched using the app icon.
res/
Contains several sub-directories for app resources. Here are just a few:

drawable-hdpi/
Directory for drawable objects (such as bitmaps) that are designed for high-density (hdpi) screens. Other drawable directories contain assets designed for other screen densities.
layout/
Directory for files that define your app's user interface.
values/
Directory for other various XML files that contain a collection of resources, such as string and color definitions.

When you build and run the default Android app, the default Activity class starts and loads a layout file that says "Hello World." The result is nothing exciting, but it's important that you understand how to run your app before you start developing.

RUN ON A REAL DEVICE

If you have a real Android-powered device, here's how you can install and run your app:

1- Plug in your device to your development machine with a USB cable. If you're developing on Windows, you might need to install the appropriate USB driver for your device. OEM USB Drivers document.
2- 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.

Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.

To run the app from Eclipse:

1- Open one of your project's files and click Run from the toolbar.
2- In the Run as window that appears, select Android Application and click OK.

OEM USB Drivers

Installing USB Drivers

Caution: You may make changes to android_winusb.inf file found inside usb_driver\ (for example, to add support for other devices), however, this will lead to security warnings when you install or upgrade the driver. Making any other changes to the driver files may break the installation process.


Windows 7


To install the Android USB driver on Windows 7 for the first time:

1- Connect your Android-powered device to your computer's USB port.
2- Right-click on Computer from your desktop or Windows Explorer, and select Manage.
3- Select Devices in the left pane.
4- Locate and expand Other device in the right pane.
5- Right-click the device name (such as Nexus S) and select Update Driver Software. This will launch the Hardware Update Wizard.
6- Select Browse my computer for driver software and click Next.
7- Click Browse and locate the USB driver folder. (The Google USB Driver is located in <sdk>\extras\google\usb_driver\.)
8- Click Next to install the driver.

Or, to upgrade an existing Android USB driver on Windows 7 with the new driver:

1- Connect your Android-powered device to your computer's USB port.
2- Right-click on Computer from your desktop or Windows Explorer, and select Manage.
3- Select Device Manager in the left pane of the Computer Management window.
4- Locate and expand Android Phone in the right pane.
5- Right-click Android Composite ADB Interface and select Update Driver. This will launch the Hardware Update Wizard.
6- Select Install from a list or specific location and click Next.
7- Select Search for the best driver in these locations; un-check Search removable media; and check Include this location in the search.
8- Click Browse and locate the USB driver folder. (The Google USB Driver is located in <sdk>\extras\google\usb_driver\.)
9- Click Next to upgrade the driver.

Windows XP


To install the Android USB driver on Windows XP for the first time:

1- Connect your Android-powered device to your computer's USB port. Windows will detect the device and launch the Hardware Update Wizard.
2- Select Install from a list or specific location and click Next.
3- Select Search for the best driver in these locations; un-check Search removable media; and check Include this location in the search.
4- Click Browse and locate the USB driver folder. (The Google USB Driver is located in <sdk>\extras\google\usb_driver\.)
5- Click Next to install the driver.

Or, to upgrade an existing Android USB driver on Windows XP with the new driver:

1- Connect your Android-powered device to your computer's USB port.
2- Right-click on My Computer from your desktop or Windows Explorer, and select Manage.
3- Select Device Manager in the left pane.
4- Locate and expand Android Phone in the right pane.
5- Right-click Android Composite ADB Interface and select Update Driver. This will launch the Hardware Update Wizard.
6- Select Install from a list or specific location and click Next.
7- Select Search for the best driver in these locations; un-check Search removable media; and check Include this location in the search.
8- Click Browse and locate the USB driver folder. (The Google USB Driver is located in <sdk>\extras\google\usb_driver\.)
9- Click Next to upgrade the driver.


Windows Vista


To install the Android USB driver on Windows Vista for the first time:

1- Connect your Android-powered device to your computer's USB port. Windows will detect the device and launch the Found New Hardware wizard.
2- Select Locate and install driver software.
3- Select Don't search online.
4- Select I don't have the disk. Show me other options.
5- Select Browse my computer for driver software.
6- Click Browse and locate the USB driver folder. (The Google USB Driver is located in <sdk>\extras\google\usb_driver\.) As long as you specified the exact location of the installation package, you may leave Include subfolders checked or unchecked—it doesn't matter.
7- Click Next. Vista may prompt you to confirm the privilege elevation required for driver installation. Confirm it.
8- When Vista asks if you'd like to install the Google ADB Interface device, click Install to install the driver.

Or, to upgrade an existing Android USB driver on Windows Vista with the new driver:

1- Connect your Android-powered device to your computer's USB port.
2- Right-click on Computer from your desktop or Windows Explorer, and select Manage.
3- Select Device Manager in the left pane.
4- Locate and expand ADB Interface in the right pane.
5- Right-click on HTC Dream Composite ADB Interface, and select Update Driver Software.
6- When Vista starts updating the driver, a prompt will ask how you want to search for the driver software. Select Browse my computer for driver software.
7- Click Browse and locate the USB driver folder. (The Google USB Driver is located in <sdk>\extras\google\usb_driver\.) As long as you specified the exact location of the installation package, you may leave Include subfolders checked or unchecked—it doesn't matter.
8- Click Next. Vista might prompt you to confirm the privilege elevation required for driver installation. Confirm it.
9- When Vista asks if you'd like to install the Google ADB Interface device, click Install to upgrade the driver.


OEM DRIVERS Download

Acer
Dell
HTC
Huawei
Intel
MTK
ZTE
Samsung



Eclipse installs the app on your connected device and starts it.

Or to run your app from a command line:

1- Change directories to the root of your Android project and execute:
ant debug
Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:
adb install bin/MyFirstApp-debug.apk
On your device, locate MyFirstActivity and open it.

RUN ON THE EMULATOR


To create an AVD:

1- Launch the Android Virtual Device Manager:
a- In Eclipse, click Android Virtual Device Manager from the toolbar.
b- From the command line, change directories to <sdk>/tools/ and execute:

android avd


2- In the Android Virtual Device Manager panel, click New.
3- Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default).
4- Click Create AVD.
5- Select the new AVD from the Android Virtual Device Manager and click Start.
6- After the emulator boots up, unlock the emulator screen.

To run the app from Eclipse:

1- Open one of your project's files and click Run from the toolbar.
2- In the Run as window that appears, select Android Application and click OK.

Eclipse installs the app on your AVD and starts it.

Or to run your app from the command line:

1- Change directories to the root of your Android project and execute:
ant debug
2- Make sure the Android SDK platform-tools/ directory is included in your PATH environment variable, then execute:
adb install bin/MyFirstApp-debug.apk
On the emulator, locate MyFirstActivity and open it.
Please Wait for Next Class....