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);
}
}
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 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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With