6

I've a very simply function like following:

public static boolean isAppInstalled(String packageName) {
    PackageManager pm = MainApp.get().getPackageManager();
    try {
        pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}

Sometimes this crashes at the line getPackageInfo with following stacktrace:

java.lang.RuntimeException: Package manager has died
    at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:151)
    ... code in my app => getPackageInfo line above ...
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(Binder.java:505)
    at android.content.pm.IPackageManager$Stub$Proxy.getPackageInfo(IPackageManager.java:2151)
    at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:145)
    ...

Any ideas why this can happen? I thought things like this only happen if an app is installed / deinstalled just at the same time, but I have an user who can repeat this and always get's this exception.

prom85
  • 16,896
  • 17
  • 122
  • 242

2 Answers2

0

Restrat your Mobile Phone after that;

  1. Clean project
  2. Rebuild Projet
  3. Compile Project
Andronicus
  • 25,419
  • 17
  • 47
  • 88
Deniz
  • 319
  • 5
  • 9
0

I am seeing the same problem, but only on Android 6. I am trying to see if adding the PackageManager.GET_META_DATA flag helps. It was suggested in the comments in this similar question: GetPackageInfo results in DeadObjectException

Flyview
  • 1,899
  • 1
  • 28
  • 46