24

Am trying to view my database tables using Android Device Monitor and It showing me Errors for reasons which i am not really sure of. And i don't have another instance of DDMS running.

Instead of showing my DDMS, Its showing me this errors

[2015-09-10 17:39:53 - ddms] Could not open Selected VM debug port (8700). Make sure you do not have another instance of DDMS or of the eclipse plugin running. If it's being used by something else, choose a new port number in the preferences.
[2015-09-10 17:39:53 - ddms] Can't bind to local 8600 for debugger
[2015-09-10 17:39:53 - ddmlib] Broken pipe
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
    at sun.nio.ch.IOUtil.write(IOUtil.java:65)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
    at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
    at com.android.ddmlib.Client.sendAndConsume(Client.java:677)
    at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:349)
    at com.android.ddmlib.Client.requestAllocationStatus(Client.java:523)
    at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:847)
    at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:815)
    at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:775)
    at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:664)
    at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:46)
    at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:592)

Please, any one knows a solution to this ???

Tosin Onikute
  • 3,883
  • 6
  • 38
  • 61

6 Answers6

41

Try killing the adb server and restarting the adb server from terminal.

adb kill-server
adb start-server

Also on your mobile device, toggle the usb debugging. Both of these combine worked for me when I had this issue.

Also you may want to consider using Stetho by Facebook, you can view your database as well as run queries with Stetho. Stetho also lets you watch network calls, view your view hierarchy and more.

VirtualProdigy
  • 1,637
  • 1
  • 20
  • 40
  • Thanks, Stetho also led me in finding another tool SQLite Browser http://sqlitebrowser.org/ which i also got by reading this answer now, http://stackoverflow.com/questions/17529766/see-database-filecontent-via-android-studio . cheers – Tosin Onikute Sep 10 '15 at 17:17
  • 2
    "toggle the usb debugging" solved my issue. So go to developer options on your android device and off, then on usb debugging. – Kamran Bigdely Nov 28 '16 at 23:46
  • Thanks, killing adb fixed it. For me it was caused by having Android Studio and Eclipse open at the same time, so I could debug two different apps. I also closed AS and restarted Eclipse just to be on the safe side. – Neph Jun 11 '18 at 14:21
  • i tried the above step it's not working for me.... cd /Users/varunagiri/Library/Android/sdk/platform-tools adb kill-server -bash: adb: command not found – Vignesh Apr 29 '19 at 09:32
8

On Mac, Open terminal and type:

    sudo nano /etc/hosts

Add following line to your hosts file

127.0.0.1        localhost

Save and exit.

In Android Studio, you can start debugging again. I got stuck with the same problem and I ended up doing above, problem solved.

Hope this helps :) .

Udit Kapahi
  • 2,277
  • 1
  • 27
  • 25
  • I don't know why this worked, but it did work for me. I tried the accepted answer a few times before I tried this one. – beyondtheteal Mar 15 '18 at 21:08
  • Man you just answered my days of struggle – SAIR May 16 '18 at 13:02
  • @SAIR glad to know it helped :D. – Udit Kapahi May 16 '18 at 13:06
  • This has been bugging me for ages and this solution was the only thing that worked. Thanks a lot. – Dan Nov 15 '18 at 14:53
  • @Dan feels good to knw that soln helped someone in same situation.. Cheers – Udit Kapahi Nov 15 '18 at 15:01
  • Years later, this solution helped me too. Before making the suggested edit to /etc/hosts, I checked what localhost was doing, and it was resolving to an internal IP for my company. (localhost..com was set up to point somewhere for some reason.) – tcobbs Jul 15 '21 at 17:50
3

For osx users

Yes you need to restart adb. Simply restart android studio should do the trick. If it's still not working, force killing the thread on port 8600 by this

[sudo] lsof -i :8600

Then for the PID

kill -9 <PID>
Community
  • 1
  • 1
Fangming
  • 24,551
  • 6
  • 100
  • 90
  • No one is listening, can run a python3 -m http.server 8600 as well. But Android studio will give this error! Any idea? – earthdan May 02 '19 at 09:32
2

A similar question helped me solve this issue here:

Android Studio and android device monitor

By opening DDMS from within Android Studio, I am able to bind and monitor my android devices with no more broken pipes or port conflicts.

Simply follow these steps to open DDMS from within android studio: Select Tools > Android > Android Device Monitor

I can only assume AS runs a DDMS instance silently, since when AS is closed, manually opening DDMS has no issues. Only when AS is running do I get this when running DDMS from the CLI

Community
  • 1
  • 1
JoshuaTree
  • 1,211
  • 14
  • 19
0

What worked for me was restarting the computer. I think this happened after force-quitting Android Studio.

Robert Columbia
  • 6,313
  • 15
  • 32
  • 40
Martin
  • 97
  • 1
  • 6
-3

in case of converting your webapp into android app.

if u give your url like this : localhost:xxxx/abc/xx then it create the problem because the port of your localhost and port of your emulator is different. you are using emulator it work like a separate device in your computer.

SO FRIENDS USE IP ADDRESS INSTEAD OF LOCALHOST AND IT WILL WORK ...101% WORK I AM SURE