简体   繁体   中英

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

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

I have fixed this bug thanks to this temporarily solution from @acoutts in https://github.com/flutter/flutter/issues/109769

dependency_overrides:
  camera_android:
    git:
      url: https://github.com/elmar001/plugins.git
      path: packages/camera/camera_android
      ref: 5172b44088a4082ff0899594614c5380457d341b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM