Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I was trying to run my application on my Android device using Android Studio, it runs fine otherwise but in this case some data was being deleted from my mobile phone and while that process wasn't done yet, Android studio was trying to install and run the app which caused my phone to get stuck for a while and restart.

So I would like to know if there is a way to get the full stack trace of the error and does this mean that my application is probably not properly structured and got killed in the middle of an important process?

Thank you.

This is the error I got at that time:

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 : I'm not asking about how to solve this error because my app runs, I want to understand what might have caused it.

like image 821
Ouissal Benameur Avatar asked Sep 04 '18 13:09

Ouissal Benameur


2 Answers

Just for some clarification :

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.

So, according to error here in Android Studio is that Gradle Deamon was trying to execute an adb command to install (push) latest generate .apk file (writing application package through socket using tcpip protocol) but connection gets lost by adb to device so that Gradle failed to execute command.

Sometimes, loose/poor connection to device causes this kind of issue.

(In some of the cases, updated incremental dex doesn't gets written to device, and .apk becomes corrupted due to outdated dex & so that it warns to reinstall apk by removing old one.)

Now, if you failed to grab logcat from Android Studio 'Logcat' window then you can still get bug report/logcat using this command in terminal

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

or use

adb logcat

to see log of device

For grabbing detailed or filtered log: link

That has nothing to do with your query: (does this mean that my application is probably not properly structured and got killed in the middle of an important process?)

So, everything will be perfectly fine once you re-run (reinstall) your .apk

like image 174
Jeel Vankhede Avatar answered Nov 08 '22 13:11

Jeel Vankhede


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

Well, I think there is not much to worry since you mention that your app is running fine. I think we should not search the problem in your app. Since it runs fine, it should be coded fine as well.

Android studio was trying to install and run the app

There we go! This is purely speculation, but I think Android Studio was the problem. When you are developing an app, every time you make changes, Android Studio will restart the app. Which is the so called instant run: https://developer.android.com/studio/run/#ir-limitations

I developed lots of native apps and I never enjoyed instant run. In rare cases, it malformed my application. UI didn't reload properly and got several issues. So whenever I develop mobile applications now, I just disable instant run.

I am mentioning instant run, since it might have broken your application while it was busy doing some I/O operations. This is not bad from your side, but I would recommend you to test and develop without using instant run for a while. Without instant run, you are guaranteed to install a full compiled application in your phone. This will or should also prevent you this issue in the future.

like image 29
gi097 Avatar answered Nov 08 '22 11:11

gi097