简体   繁体   中英

Android Reconnect Debugger

Using eclipse, I run my emulator in debug mode and I'm testing network outages by simulating them by pressing F8 in the emulator.

When I disable the network, my debugging connection is lost and the emulator doesn't show up in the list even if I try to redeploy the apk with the debug run. So I have to close and restart my emulator.

So my questions in summary is: Is there anyway to reconnect eclipse to the emulator in debug mode? If not, is there a way to redeploy the apk in debug mode without me having to restart my emulator?

A side note:

I tried looking in the DDMS perspective as mentioned in: Reconnect to debug process on Android using Eclipse with ADT but no devices show up.

In eclipse, open the 'DDMS Perspective'

You will notice an upside down triangle on the far right of the 'Devices' tab.

In this menu, you can select 'Reset ADB'. This will reset the ADB server, and reconnect your emulator.

You will likely see an error message telling you the process didn't restart properly - you can ignore this message.

I've never tried this with intentionally suspending the emulated network, but the android emulator is actually an ADB-over-TCP target with a special name. For some "random" losses of connection, you can recover by creating a new explicit adb-over-tcp session to the emulator.

If you had emulator-5554, you would connect to it with

adb tcp 127.0.0.1:5555 

which is to say, the loopback address of the development machine, and one port higher than the control port.

Again, I don't know that this will work for your particular cause of adb failure, but it does work for some.

Also (just answered this elsewhere today) if you have multiple connected adb targets and so need to explicitly specify this reconnected emulator with the -s option to adb, you would need both the address and port, for example

adb -s 127.0.0.1:5555 some_adb_command

Another thing you might try is killing the adb server, then trying to use adb again (which will launch a new adb server) in the hope that it picks up the running emulator instance.

What about

adb kill-server
adb start-server

in console(terminal)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM