未知故障(cmd:调用服务包失败:管道损坏(32))

Unknown failure (cmd:Failure calling service package: Broken pipe (32))

我尝试使用 Android Studio 在我的 Android 设备上 运行 我的应用程序,否则 运行 没问题,但在这种情况下一些数据被删除从我的手机 phone 虽然该过程尚未完成,但 Android 工作室正在尝试安装 运行 导致我的 phone 卡住了一段时间的应用程序并重新启动。

所以我想知道是否有办法获取错误的完整堆栈跟踪,这是否意味着我的应用程序可能结构不正确并被终止在一个重要的过程中?

谢谢。

这是我当时得到的错误:

Installation failed with message Failed to finalize session : Unknown failure (cmd:Failure calling service package: Broken pipe (32)).

It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.


PS :我不是在询问如何解决此错误,因为我的应用 运行s,我想了解可能导致的原因它。

does this mean that my application is probably not properly structured and got killed in the middle of an important process?

好吧,既然您提到您的应用 运行 没问题,我认为没有什么可担心的。我认为我们不应该在您的应用程序中搜索问题。既然它 运行 没问题,它的编码也应该没问题。

Android studio was trying to install and run the app

我们开始了!这纯粹是猜测,但我认为 Android Studio 是问题所在。当您开发应用程序时,每次您进行更改时,Android Studio 都会重新启动该应用程序。这就是所谓的即时运行https://developer.android.com/studio/run/#ir-limitations

我开发了很多本机应用程序,但我从来没有享受过即时 运行。在极少数情况下,它会使我的应用程序格式错误。 UI 没有正确重新加载并遇到了几个问题。所以现在每当我开发移动应用程序时,我都会禁用 instant 运行。

我提到的是即时 运行,因为它可能在忙于执行一些 I/O 操作时破坏了您的应用程序。这对你来说还不错,但我建议你暂时不使用 instant 运行 进行测试和开发。如果没有即时 运行,您肯定会在 phone 中安装完整编译的应用程序。这将或应该也能防止您以后遇到这个问题。

澄清一下:

What exactly the Broken Pipe error means ?

It means that when a process requests an output to pipe or socket, which was closed by peer.

因此,根据 Android Studio 中的错误,Gradle Deamon 试图执行用于安装 (push) 最新生成 .apk 文件 (使用 tcpip 协议通过套接字编写应用程序包) 但连接丢失的 adb 命令通过 adb 到设备,以便 Gradle 无法执行命令。

有时,loose/poor 连接到设备会导致此类问题。

(在某些情况下,更新的 incremental dex 不会写入设备,并且 .apk 由于过时的 dex 而损坏,因此它会警告重新安装 apk通过删除旧的。)

现在,如果您未能从 Android Studio 'Logcat' window 中获取 logcat,那么您仍然会遇到错误report/logcat 在终端中使用此命令

adb bugreport 'path to store bug report(optional)'

或使用

adb logcat

查看设备日志

获取详细或过滤后的日志:link

这与您的查询无关:(这是否意味着我的应用程序可能结构不正确并在重要进程中被杀死?)

因此,一旦您重新运行(重新安装)您的.apk

,一切都会很好