2

I've connected my Nexus One device to the PC. The USB debugging on the device is on. When I run the app from Eclipse, it works fine on the device. However, if I attempt to Debug, i get a message box on the Nexus One stating that it's waiting for the debugger to attach. On the Eclipse side, after about 20 or so seconds of thinking I get the following in the Console

Attempting to connect debugger to 'com.angryhacker.printerfun' on port 8600
Launch error: Failed to connect to remote VM. Connection timed out.

What am I missing?

AngryHacker
  • 59,598
  • 102
  • 325
  • 594

4 Answers4

3

1) Enabling USB debugging on the device is the first step. It sounds like you've done that ... but it wouldn't hurt to double check everything:

http://developer.android.com/guide/developing/device.html

2) As the same link also says, make sure debugging is enabled in your project's AndroidManifest.xml

3) Definitely check your host PC's firewall (for example, Windows firewall) to make sure it isn't blocking any ports.

4) For troubleshooting purposes, you can also try:

a) setting a longer timeout

b) trying a different port#

ADDENDUM:

Q: I'm assuming you've NEVER successfully downloaded and run an .apk from your Eclipse compiler to your NexusOne handset. Correct?

Q: I'm also assuming that when you try "Debug As", you see your physical handset in the GUI, and you've selected it. Correct?

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • 1
    Q1. I can run the .apk on the device just fine. The debugging is what does not work. – AngryHacker Dec 27 '11 at 06:44
  • Q2. Hmmm, I didn't think to check there. Nothing there. Nor does Debug Configurations menu item working - just says `unhandled event loop exception` in the Error log window. The error comes from org.eclipse.ui. - Maybe it is time for reinstall. – AngryHacker Dec 27 '11 at 06:47
2

Test to see if it works when your PC is not connected to the net (no WiFi, no network cables). If it does work under those conditions, then it may be that you need to make sure that addresses are resolving to localhost properly. The messages that DDMS and adb.exe use for debugging and communicating to the VM must properly resolve to localhost on your PC. (Yes, it's odd that other commands using DDMS & adb work just fine but debugging doesn't. Seems that something in DDMS or adb needs to be standardized so they all work under the same conditions.)

If you need to make sure that things are resolving to localhost properly:

1) Make sure that this line is in your /Windows/System32/drivers/etc/hosts file:

127.0.0.1  localhost

(you can have any amount of whitespace between "127.0.0.1" and "localhost")

2) If that doesn't work, then you may need to also add your PC's IPv4 address to the hosts file, and resolve it to localhost. (You can find out the IPv4 address for your machine with the ipconfig command.) If, for example, your machine's IPv4 address is 192.168.1.100 then you'd add the line

192.168.1.100  localhost

to your hosts file. (You can add it below the "127.0.0.1 localhost" line in the file.)

You can verify that adb (and your emulator if you're running one) is listening on ports by using the netstat -b command. (Note that you need admin privileges for the -b option. I open a command window using "Run as Administrator.")

aenw
  • 841
  • 9
  • 18
0

I had the same error on Windows 8. I tried all the points as suggested by the answer from @paulsm4 but still nothing worked.

The problem got fixed when I set the compatibility mode for eclipse.exe to Windows XP SP3.

Hint: Right click on eclipse.exe => Properties => Compatibility => Compatibility Mode => Set the compatibility mode to "Windows XP (Service Pack 3)"

KK_35
  • 93
  • 1
  • 6
0

One more possible cause of such issues is the intent-filters in your activity.

When some intents are defined for your activity, you might not be able to debug the application. For example:

<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<action android:name="com.android.setupwizard.COMPLETED" />
Danke Xie
  • 1,757
  • 17
  • 13