Android 是什么导致了 IOException 和 Broken pipe
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11065509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what caused IOException and Broken pipe
提问by manuzhang
My AVD is of API 15, I don't know why but the following message keeps coming up whenever I run an application on emulator. It doesn't seem to have caused any trouble except for the error message in console.
我的 AVD 是 API 15,我不知道为什么,但是每当我在模拟器上运行应用程序时,以下消息不断出现。除了控制台中的错误消息外,它似乎没有引起任何麻烦。
[2012-06-17 00:03:26 - ddmlib] Broken pipe
java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:122)
at sun.nio.ch.IOUtil.write(IOUtil.java:93)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:352)
at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
at com.android.ddmlib.Client.sendAndConsume(Client.java:575)
at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
at com.android.ddmlib.Client.requestAllocationStatus(Client.java:421)
at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:837)
at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:805)
at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:765)
at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:652)
at com.android.ddmlib.DeviceMonitor.access0(DeviceMonitor.java:44)
at com.android.ddmlib.DeviceMonitor.run(DeviceMonitor.java:580)
What could be the cause?
可能是什么原因?
回答by Abhishek Patidar
If someone uses both eclipse and android studio together, then this error will be thrown by eclipse. So even if you select the device through DDMS, its gonna throw this error.
如果有人同时使用eclipse和android studio,那么eclipse就会抛出这个错误。因此,即使您通过 DDMS 选择设备,它也会抛出此错误。
回答by Amir Uval
Old question, but still relevant and I didn't see any other answer with this information:
老问题,但仍然相关,我没有看到有关此信息的任何其他答案:
For me it happened when another Eclipse was running at the same time, with DDMS competing over the same socket as the eclipse trying to connect to the Android device.
对我来说,它发生在另一个 Eclipse 同时运行时,DDMS 与试图连接到 Android 设备的 Eclipse 在同一个套接字上竞争。
Solution was to close the other Eclipse. Hope it helps someone.
解决方案是关闭另一个Eclipse。希望它可以帮助某人。
Update: Probably a better solution is to edit the DDMS port of the other eclipse to something you don't use. So it's out of the race.
更新:可能更好的解决方案是将另一个 Eclipse 的 DDMS 端口编辑为您不使用的内容。所以它不在比赛中。
回答by kizzx2
This happened to me when I had both monitor
and Eclipse ADT open. Try closing all Android related stuff and then do a adb kill-server && sleep 5 && adb devices
and then start your tool (Eclipse/Ant/AS) again.
当我同时monitor
打开 Eclipse ADT时,这发生在我身上。尝试关闭所有与 Android 相关的内容,然后adb kill-server && sleep 5 && adb devices
再次启动您的工具(Eclipse/Ant/AS)。
回答by user207421
'Broken pipe' means you have written data to a connection that had already been closed by the peer. Solution: don't. It is essentially an application protocol error.
“断管”意味着您已将数据写入已被对等方关闭的连接。解决办法:不要。它本质上是一个应用程序协议错误。
回答by Hiep
I guess that the client (Eclipse) communicate with the Server (your Emulator) by Pipe protocol (This protocol is well-know to communicate 2 process on the same machine).
我猜客户端(Eclipse)通过管道协议与服务器(你的模拟器)通信(众所周知,该协议可以在同一台机器上通信2个进程)。
The communication channel can be broken sometimes. (There are possible 100+ reason for that)
通信通道有时会中断。(可能有 100 多个原因)
To solve this issue: restart the emulator (AVD). Maybe you will have to wait a moment (~1min??) so Eclipse can restore the Pipe channel and your Log Cat will return. Otherwise, restart both Eclipse & the emulator to get rid of this error.
要解决此问题:重新启动模拟器 (AVD)。也许您需要稍等片刻(~1 分钟??),以便 Eclipse 可以恢复管道通道并且您的 Log Cat 将返回。否则,重新启动 Eclipse 和模拟器以消除此错误。
回答by Suresh Parmar
The most common reason I've had for a "broken pipe" is that one machine (of a pair communicating via socket) has shut down its end of the socket before communication was complete. About half of those were because the program communicating on that socket had terminated.
我对“管道损坏”的最常见原因是(一对通过套接字通信的)机器在通信完成之前关闭了它的套接字端。其中大约一半是因为在该套接字上通信的程序已终止。
If the program sending bytes sends them out and immediately shuts down the socket or terminates itself, it is possible for the socket to cease functioning before the bytes have been transmitted and read.
如果发送字节的程序将它们发送出去并立即关闭套接字或自行终止,则套接字有可能在字节被传输和读取之前停止运行。
Try putting pauses anywhere you are shutting down the socket and before you allow the program to terminate to see if that helps.
尝试在您关闭套接字的任何位置以及允许程序终止之前暂停以查看是否有帮助。
FYI: "pipe" and "socket" are terms that get used interchangeably sometimes.
仅供参考:“管道”和“套接字”是有时可以互换使用的术语。
回答by Ben Pearson
I noticed this happening frequently (every 5 mins or so) recently. The frequency seemed to increase if I had both a physical device and an emulator running.
我最近注意到这种情况经常发生(每 5 分钟左右)。如果我同时运行物理设备和模拟器,频率似乎会增加。
Stopping the emulator and only using the physical device for debugging stopped it from happening as often - now I only see it once or twice a day.
停止模拟器并仅使用物理设备进行调试可以阻止它经常发生 - 现在我每天只能看到一两次。
To resolve it when it happens, you don't need to close down the emulator or reboot the device - turning USB Debugging Mode off and back on should make it show up again under adb.
要在它发生时解决它,您不需要关闭模拟器或重新启动设备 - 关闭并重新打开 USB 调试模式应该使它再次显示在 adb 下。
回答by Amir Al
I have been struggling with this problem for a long time. Whenever I wanted to debug android mobile application with Chrome's debug tool I got disconnected every 5 mintutes.
我一直在努力解决这个问题。每当我想使用 Chrome 的调试工具调试 Android 移动应用程序时,我每 5 分钟就会断开一次连接。
I found out that the cause of this is indeed other process using connection to mobile phone that is running behind in OS that breaks the communication between mobile phone and OS.
我发现造成这种情况的原因确实是其他使用与手机连接的进程在操作系统中运行,从而中断了手机与操作系统之间的通信。
I use Macbook Pro and I was running IntelliJ IDEA debugger + Android File Transfer (didn't knew this was running behind) and Chrome's debugger tool. When I closed Android File Transfer process with "Activity Monitor" tool everything was working well, no more disconnection between mobile phone and OS. My suggestion is to check always if you are running other Android process.
我使用 Macbook Pro 并且我正在运行 IntelliJ IDEA 调试器 + Android 文件传输(不知道这是在运行)和 Chrome 的调试器工具。当我使用“活动监视器”工具关闭 Android 文件传输过程时,一切正常,手机和操作系统之间不再断开连接。我的建议是始终检查您是否正在运行其他 Android 进程。
回答by Bantu
In case any one else did not find any solution to this. In eclipses Neon, this happened when i had two DDMS jars in the plugins directory. I had the andmore.ddms.jar and com.android_ddms.jar. Deleting one solves the error, i guess they both compete to connect to the same port.
万一其他人没有找到任何解决方案。在 eclipses Neon 中,这发生在我的插件目录中有两个 DDMS jar 时。我有 andmore.ddms.jar 和 com.android_ddms.jar。删除一个解决了错误,我猜他们都竞争连接到同一个端口。
回答by Mr.Ghamkhar
restarting the android device fixed my problem
重新启动 android 设备解决了我的问题