Android Studio unable to run project on device?

2019-06-16 09:29发布

问题:

I am getting the following error. I couldn't find why this happens on the internet either.

ddms: Can't bind to local 8601 for debugger
ddmlib: Broken pipe
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcher.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:69)
    at sun.nio.ch.IOUtil.write(IOUtil.java:40)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:336)
    at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
    at com.android.ddmlib.Client.sendAndConsume(Client.java:675)
    at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:342)
    at com.android.ddmlib.Client.requestAllocationStatus(Client.java:521)
    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)

ddmlib: Broken pipe
java.io.IOException: Broken pipe
    at sun.nio.ch.FileDispatcher.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:69)
    at sun.nio.ch.IOUtil.write(IOUtil.java:40)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:336)
    at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
    at com.android.ddmlib.Client.sendAndConsume(Client.java:675)
    at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:342)
    at com.android.ddmlib.Client.requestAllocationStatus(Client.java:521)
    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)

Note:

My device Nexus that runs 5.0.2

My android studio is 1.0.1

My platform is mac mavericks

I am just trying to run the Login template app nothing more.

Thanks

回答1:

You might have both Android studio and Eclipse open

  • Close both the applications and open the one which you are going to use.

  • if it didn't solve the problem the port is used by some other app so restart the system

  • or else kill port using a command if the problem still remains unsolved



回答2:

adb kill-server

then

adb start-server

worked for me!



回答3:

Restart your computer and check

If you are using Linux try to kill the port using

fuser -k 8601/tcp

If you are using mac try to kill the port using

lsof -P | grep '8601' | awk '{print $2}' | xargs kill

Here is the ref for osx



回答4:

There is nothing that much serious with this exception. Simply you need to unplug your USB cable from the port, restart your device and restart your Android Studio as well. Surely this exception will be removed. This worked for me, hope you will also get rid of it.



回答5:

This is just a dumb thing done by the system which as trouble finding localhost it seems. Take a look in here, many people have this question, and it's quite easy to fix.



回答6:

I am on OS X 10.9.5. Sometimes I get this error too. Usually I disconnect the device -> restart the adb (or quit the android studio and then start again)->connect the device -> run again. [make sure you are not running adb from another eclipse/studio]

See if this helps you.



回答7:

Simply using adb kill-server addressed the problem for me.



回答8:

I tried all the solutions above: restarted studio, restarted devices, killed all studio processes, killed the ports listening...

Eventually the only thing that worked was File -> Invalidate Caches / Restart...

Also changing the USB cable could help...