skip to Main Content

My app keeps crashing when an Android 13 user try to launch the camera (using the package camera 0.10.1) :

 final cameras = await availableCameras();
 final selectedCamera = cameras.first;

I am getting this stack trace RuntimeException :

Failure delivering result ResultInfo{who=@android:requestPermissions:,
request=9796, result=-1, data=Intent {
act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to
activity {edouard.immo/edouard.immo.MainActivity}:
java.lang.NullPointerException: Attempt to invoke virtual method ‘int
android.media.EncoderProfiles$VideoProfile.getWidth()’ on a null
object reference

I well have added this permission in my manifest : READ_MEDIA_IMAGES and READ_MEDIA_VIDEO

I really do not know what to do 🙁

2

Answers


  1. It’s a bug of camera library: https://github.com/flutter/flutter/issues/109769

    While we wait for the fix move compileSdkVersion 33 to 32 in build.gradle

    Login or Signup to reply.
  2. I solved the problem by adding uses-feature for the camera in the AndroidManifest.xml file.

    <uses-feature android:name="android.hardware.camera" android:required="true"/>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search