iffandybaguspradana.blogspot.com - With an
Android-powered device, you can develop and debug your Android applications
just as you would on the emulator. Before you can start, there are just a few
things to do:
1.
Declare your
application as "debuggable" in your Android Manifest.
When using Eclipse, you can skip this step,
because running your app directly from the Eclipse IDE automatically enables
debugging.
In the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.
Note: If you manually enable debugging in the manifest file, be
sure to disable it before you build for release (your published application
should usually not be debuggable).
2.
Enable USB
debugging on your device.
o On most devices running Android 3.2 or older,
you can find the option under Settings > Applications >
Development.
o 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.
3.
Set up your system to
detect your device.
o If you're developing on Windows, you need to
install a USB driver for adb. For an installation guide and links to OEM
drivers, see the OEM USB Drivers document.
o If you're developing on Mac OS X, it just
works. Skip this step.
o If you're developing on Ubuntu Linux, you need
to add a udev rules file that contains a USB
configuration for each type of device you want to use for development. In the
rules file, each device manufacturer is identified by a unique vendor ID, as
specified by the ATTR{idVendor} property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device
detection on Ubuntu Linux:
a.
Log in as root and
create this file: /etc/udev/rules.d/51-android.rules.
Use this format to add each vendor to the
file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUPdefines which Unix group owns the device node.
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUPdefines which Unix group owns the device node.
Note: The rule syntax may vary slightly depending on your
environment. Consult the udev documentation for your system as needed.
For an overview of rule syntax, see this guide to writing udev rules.
b.
Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules
chmod a+r /etc/udev/rules.d/51-android.rules
When plugged in over
USB, can verify that your device is connected by executing adb devices from
your SDK platform-tools/ directory. If connected, you'll see the
device name listed as a "device."
If using Eclipse, run
or debug your application as usual. You will be presented with a Device
Chooser dialog that lists the available emulator(s) and connected
device(s). Select the device upon which you want to install and run the
application.
If using the Android Debug Bridge (adb), you can issue commands
with the -d flag to target your connected device.
0 comments:
Post a Comment