Developing on Device Hardware
If you have an Android device, you can develop and debug your Android applications just as usual. Launching your apps on a device works just the same as on the emulator, but there are a few things to do before you can start.
- Declare your application as "debuggable" in your Android Manifest. In Eclipse, you can do this from the Application tab when viewing the Manifest (on the right side, set Debuggable to true). Otherwise, in the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.
- Turn on "USB Debugging" on your device. On the T-Mobile G1, go to the home screen, press MENU, select Applications > Development, then enable USB debugging.
- Setup your system to detect your device.
- If you're developing on Windows (32-bit only), you need to install the USB driver for adb:
- Download the driver ZIP file (android_usb_windows.zip) and unzip it.
- Connect your Android device via USB. When the Found New Hardware Wizard appears, you'll be asked if you'd like Windows Update to search for software, select No, not this time and click Next.
- Select Install from a list or specified location and click Next.
- Select Search for the best driver in these locations. Browse and select the unzipped file.
- Click Finish. You're all set.
- If you're developing on Mac OS X, it just works. Skip this step.
- If you're developing on Ubuntu Linux, you need to add a rules file:
- Login as root and create this file: /etc/udev/rules.d/50-android.rules. For Gusty/Hardy, edit the file to read:
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"
For Dapper, edit the file to read:
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"
- Now execute:
chmod a+rx /etc/udev/rules.d/50-android.rules
You can verify that your device is connected by executing adb devices from your SDK tools/ directory. If connected, you'll see the device name listed as a "device."
If using Eclipse, select run or debug as usual. If you have an emulator running, then you will be presented with a
Device Chooser dialog that lists the emulator(s) running and the connected device(s). Otherwise, the device will be used by default, instead of launching a new emulator.
If using the
Android Debug Bridge (adb), you can issue commands with the -d flag to target your connected device.
Installing an Application after your connected
You can use adb to copy an application from your development computer and install it on an emulator/device instance. To do so, use the install command. With the command, you must specify the path to the .apk file that you want to install:
adb install <path_to_apk>For more information about how to create an .apk file that you can install on an emulator/device instance, see
Android Asset Packaging Tool (aapt).
Note that, if you are using the Eclipse IDE and have the ADT plugin installed, you do not need to use adb (or aapt) directly to install your application on the emulator/device. Instead, the ADT plugin handles the packaging and installation of the application for you.
Source: Google =)