Solving "Package manager has died" RuntimeException
Asked Answered
S

1

10

I have an Android app that should list all installed apps on a device (no root). I have tried both getInstalledApplications(0) and getInstalledPackages(0) methods of PackageManager, but on some devices, which do apparently have too many apps installed, I'm getting "Package manager has died" RuntimeException (I receive them via error reporting service of Google Play). This is due to a well-known limitation of 1MB per 1 call in IPC used internally by Android.

How to workaround this? I don't mind to request the long list by chunks, but I don't see any means for that. Only 2 abovementioned methods are available.

Straightout answered 12/6, 2014 at 12:41 Comment(3)
Wow, how many apps do you have on the device? Anyway, the 1MB per call I think is per all calls ongoing? So, do you have other IPCs going on?like Content Provider or Intents? If you have large other transactions going on, then the limit for this call will be much lower.Figone
That's not my devices. This app is published on Google Play, and having thousands of installs I receive approx. 1 such exception per week. I don't have any other transactions - just a single call to getInstalledPackages(0). AFAIK from Internet/Google groups, the limit of 1MB is for a single call.Straightout
Wow, I don't have much to help you then, But if it is a TransactionTooLarge exception, from the page on that exception at Google it is stated: The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size.Figone
S
3

The issue has been fixed since Android 5.1. You may find details in the Android issuetracker.

Straightout answered 21/6, 2017 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.