Unfortunately, Package Installer has stopped while requesting permission in Marshmallow
<p>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.</p>

<p>Here is the code snippet where I am requesting the permission</p>

<pre><code>    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);
    }
}
</code></pre>