Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug on a real device (using Eclipse/ADT)

I'm trying to figure out how to debug applications directly on my phone (HTC Desire).

I've installed the USB driver that came with the phone and the phone is listed when using "adb devices".

How do I configure eclipse/ADT to launch on the phone instead of launching the emulator/virtual device?

like image 663
jgauffin Avatar asked Apr 26 '10 14:04

jgauffin


People also ask

How to debug in Eclipse ADT?

Double-click on a breakpoint to jump to its locations in the source code. Mark or unmark a breakpoint to activate or deactivate it. Any such changes are effective immediately in the current debugging session. The editor showig the code that you are debugging.

How do you debug a physical device?

On the device, open the Settings app, select Developer options, and then enable USB debugging (if applicable). Note: If you do not see Developer options, follow the instructions to enable developer options. Set up your system to detect your device.

How to debug Android app in Eclipse?

either start the app by right clicking on the project and select Debug As -> Android Application or by running it normally and later in the DDMS perspective select the running app in your devices pane and click on the green bug.

How to add DDMS in Eclipse?

Select Help > Software Updates. Select the Available Software tab. If there are updates available, select Android DDMS, Android Development Tools, and Android Hierarchy Viewer, then click Update. In the resulting Available Updates dialog, ensure that each of the listed tools are selected, then click Next.


1 Answers

With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator.

1. Declare your application as "debuggable" in AndroidManifest.xml.

<application     android:debuggable="true"     ... >     ... </application> 

2. On your handset, navigate to Settings > Security and check Unknown sources

enter image description here

3. Go to Settings > Developer Options and check USB debugging
Note that if Developer Options is invisible you will need to navigate to Settings > About Phone and tap on Build number several times until you are notified that it has been unlocked.

enter image description here

4. Set up your system to detect your device.
Follow the instructions below for your OS:


Windows Users

Install the Google USB Driver from the ADT SDK Manager
(Support for: ADP1, ADP2, Verizon Droid, Nexus One, Nexus S).

enter image description here

For devices not listed above, install an OEM driver for your device


Mac OS X

Your device should automatically work; Go to the next step


Ubuntu Linux

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, click here. To set up device detection on Ubuntu Linux:

  1. Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
  2. 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 GROUP defines which Unix group owns the device node.
  3. Now execute: chmod a+r /etc/udev/rules.d/51-android.rules

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.


5. Run the project with your connected device.

With Eclipse/ADT: 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).

With ADB: issue commands with the -d flag to target your connected device.

Still need help? Click here for the full guide.

like image 160
Sachin Gurnani Avatar answered Sep 25 '22 06:09

Sachin Gurnani