You can make the CAMERA permission optional, so the app continues to function even if the user denies it. The key is to:
✅ 1. Declare the Permission in the Manifest (but don’t make it required):
<uses-permission android:name="android.permission.CAMERA" />
This only informs the system that your app might request the camera—it doesn’t force the app to crash if not granted.
✅ 2. Request the Permission at Runtime (for Android 6.0+):
You must check and request the permission at runtime before accessing the camera.
Example in Kotlin:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
arrayOf(Manifest.permission.CAMERA),
CAMERA_PERMISSION_REQUEST_CODE)
} else {
// Permission already granted, proceed with camera
}
✅ 3. Handle Denial Gracefully:
If the user denies access, don’t crash or force close the app. Instead, show a message or disable camera features:
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
if (requestCode == CAMERA_PERMISSION_REQUEST_CODE) {
if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
// Permission granted — open camera
} else {
// Permission denied — disable camera feature or show explanation
Toast.makeText(this, "Camera permission denied. Some features may not work.", Toast.LENGTH_SHORT).show()
}
}
}
✅ 4. (Optional) Use <uses-feature> if You Want to Make It Optional for Play Store Filtering
In your AndroidManifest.xml, add:
<uses-feature android:name="android.hardware.camera" android:required="false" />
This tells Google Play that your app can still run on devices without a camera.
📌 Summary:
| Feature | Required? | Notes |
|---|---|---|
| Declared, but not enforced | Needed to allow requesting at runtime | |
| Runtime Permission | Yes (API 23+) | Request manually and handle denial |
| Optional (set required=”false”) | Ensures Play Store doesn’t filter out devices without a camera |
I have but the store still complains. what to do with uses-permission
✅ Problem:
You set:
<uses-feature android:name="android.hardware.camera" android:required="false" />
…but you’re still getting Google Play warnings like:
Your app uses the camera hardware feature but does not declare it as optional.
❗ Why?
Google Play automatically infers that your app requires the camera if:
- You use
<uses-permission android:name="android.permission.CAMERA" />, and - You don’t clearly make the permission optional in both features and permissions.
✅ Solution:
To make Google Play understand that the camera is optional and your app supports devices without a camera:
✔️ 1. Keep this in your AndroidManifest.xml:
<uses-feature android:name="android.hardware.camera" android:required="false" />
✔️ 2. Do NOT remove <uses-permission>, but that’s NOT enough — so:
Use a conditional permission request (already good).
✔️ 3. Add a comment or metadata if using libraries like CameraX
If you’re using CameraX, it might be triggering extra feature detection. To avoid this, also exclude unnecessary features using:
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
OR explicitly exclude all advanced camera features as optional:
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
✔️ 4. Final AndroidManifest.xml example:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
✅ Summary
| Element | Action |
|---|---|
<uses-permission android:name="android.permission.CAMERA" /> |
✅ Keep it |
<uses-feature android:name="android.hardware.camera" android:required="false" /> |
✅ Required |
Additional <uses-feature> entries for front camera, autofocus, etc. |
✅ Optional but recommended to stop Play Store warnings |
| ✅ Required for Android 6.0+ |
✅ Your app can still work if you remove:
<uses-permission android:name="android.permission.CAMERA" />
But only if:
- Your app doesn’t access the camera directly via
Camera,Camera2, orCameraXAPIs, or - You only launch the system camera app using an Intent, like:
val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE)
🔸 In this case, the system camera app handles the permission, not your app. So you don’t need the CAMERA permission.
❌ NO, your app will NOT work properly without the permission if:
- You use APIs like:
Camera.open()CameraManagerCameraX- Any library that accesses the camera stream directly
- You expect to access the camera feed inside your app
In these cases, removing the permission will cause:
- SecurityException
- Blank camera preview
- Or outright crashes
✅ Recommended: If You Want Optional Camera Use
If your app can run without a camera, but has optional features using it:
- Keep the permission:
<uses-permission android:name="android.permission.CAMERA" /> - Declare camera features as not required:
<uses-feature android:name="android.hardware.camera" android:required="false" /> - At runtime:
- Check for camera availability
- Request permission dynamically
- Gracefully degrade if camera isn’t available or permission is denied
(Update) Last minute Camera Permission Fix
There is newer tag that fixes the requirement of the permission:
<uses-permission-sdk-23 android:name="android.permission.CAMERA" />
https://developer.android.com/guide/topics/manifest/uses-permission-sdk-23-element It takes care of targeting the requirement of the permission – according the the version of the underlying OS.
