Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unfortunately, Package Installer has stopped while requesting permission in Marshmallow

I am trying to request permission to seek permission to read storage. After recent Android Studio upgrade, I started getting error "Unfortunately, Package Installer has stopped" while requesting permission and the permission request dialog does not come up.

Here is the code snippet where I am requesting the permission

    int readPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
    int writePermission = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (readPermission != PackageManager.PERMISSION_GRANTED || writePermission != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE},
                REQUEST_READWRITE_STORAGE);
    }
}
like image 930
Ananth Avatar asked Apr 13 '16 15:04

Ananth


People also ask

How do I access package installer?

If you're curious, you can find Package Installer by going to the Apps menu of your device settings and enabling Show system apps.

Is it safe to remove package installer?

Is it possible? Since Package Installer is built into the Android OS, it is not possible for a normal user to remove the package installer from the device.


2 Answers

I had the same issue. I forgot to add same permissions in manifest. I added these permissions in manifest as well, as mike said. Then clean and build and it worked like a charm.

Conclusion: If you are giving the permissions programmatically in class then make sure the same permissions you must declare in AndroidManifest.xml file.

like image 101
Däñish Shärmà Avatar answered Sep 22 '22 13:09

Däñish Shärmà


I had tried this on 2 phones but no luck.

This time, I added the permissions back to manifest file, did clean project and ran again. It worked this time.

like image 24
Ananth Avatar answered Sep 19 '22 13:09

Ananth