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
It’s a bug of camera library: https://github.com/flutter/flutter/issues/109769
While we wait for the fix move
compileSdkVersion 33
to32
in build.gradleI 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"/>