APK errors

SecurityException: permission denied

Error text

java.lang.SecurityException: Permission Denial: opening provider ... requires android.permission.READ_MEDIA_IMAGES
SecurityException: Neither user 10123 nor current process has android.permission.CAMERA

Cause

The code calls an operation that needs a permission, but either the manifest lacks it or the user did not grant it at runtime.

Step-by-step fix

  1. Check that the <uses-permission> line is in AndroidManifest.xml.
  2. Dangerous permissions (camera, location, microphone) must be asked at runtime with requestPermissions or the Activity Result API.
  3. On Android 13+ use new permissions such as READ_MEDIA_IMAGES instead of READ_EXTERNAL_STORAGE.
  4. If denied, the app must not crash; it should show an explanation.
  5. For testing, grant with adb shell pm grant or reset with pm reset-permissions.

Example commands

adb shell pm grant com.example.app android.permission.CAMERA
adb shell dumpsys package com.example.app | grep -A3 "granted=false"
adb shell pm reset-permissions

How to prevent it

Ask for each permission right before first use, with an explanation.

Author and license: Nibras Code