androidfluttercameracrashandroid-13

Flutter Camera with Android 13 : my app keeps crashing


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 :(


Solution

  • 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"/>