Skip to content

Camera permission issue on Android #116

@DerProfessor

Description

@DerProfessor

There exists an issue with the camera permission on Android that causes the main app to crash. If this library is integrated in a Flutter app and used on Android to scan documents with the provided document scanner (through MLKit/Play services) a crash occurs if a user selects the one-time permission for the camera and scans documents for more than one minute.

The problem is that this library requests the camera permission. If the app is used on Android and the provided document scanner from MLKit is used, the permission itself is provided through Play services. I tested this by removing the permission request in this library. If a user selects the one-time permission for the camera and the document scanner activity starts, a behavior begins, that is best described in this issue by fabiendem (react-native).
TLDR: The main app is set into background and after one minute the Android OS revokes the camera permission and kills the main app process. This is not immediately noticed due to the document scanner still being in the foreground. It is not a bug but intended behavior on Android. This is the logcat output when the one-time permission expires and is revoked by the operating system:

2025-11-24 15:28:57.188  1386-1386  OneTimePer...serManager system_server                        I  One time session expired for com.example.frontend (10327). deviceID 0
2025-11-24 15:28:57.220 27035-27404 Permission...erviceImpl com....android.permissioncontroller  I  Permission grant result requestId=-1688396230408645273 callingUid=10327 callingPackage=com.example.frontend permission=android.permission.CAMERA isImplicit=false result=15
2025-11-24 15:28:57.231  1386-1550  ActivityManager         system_server                        I  Killing 27093:com.example.frontend/u0a327 (adj 850): one-time permission revoked

Currently my workaround is to only request the camera permission if the app runs on iOS. I cannot test this platform so I keep the check and assume most Android users have Play services installed.

I am not sure what alternative approach might be good. We could move the permission request to the native code itself and remove it on the Flutter end, only keeping the platform method call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions