Skip to content

Attempt to invoke virtual method 'android.view.Surface android.media.ImageReader.getSurface()' on a null object reference #19595

@aravindhkumar23

Description

@aravindhkumar23

App crashes when users gives permission to access the gallery for the very first time with error message showing

07-20 12:41:37.841 4132-4132/com.----.--- E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.----.-----, PID: 4132
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Surface android.media.ImageReader.getSurface()' on a null object reference
        at io.flutter.plugins.camera.CameraPlugin$Camera.startPreview(CameraPlugin.java:676)
        at io.flutter.plugins.camera.CameraPlugin$Camera.access$2000(CameraPlugin.java:243)
        at io.flutter.plugins.camera.CameraPlugin$Camera$3.onOpened(CameraPlugin.java:443)
        at android.hardware.camera2.impl.CameraDeviceImpl$1.run(CameraDeviceImpl.java:139)
        at android.os.Handler.handleCallback(Handler.java:789)
        at android.os.Handler.dispatchMessage(Handler.java:98)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Version:
Flutter 0.5.1
camera: "^0.2.1"
image_picker: "^0.4.5"

Steps To Reproduce,

  1. Create a Stack view with CameraPreview with 2 button to capture and open gallery
  2. Click on open gallery button (At first time it asks for permission click allow -> CRASHED)
    open gallery by using final File galleryImagePath = await ImagePicker.pickImage(source:ImageSource.gallery);

sample code to Reproduce CameraView - sample code

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolecustomer: crowdAffects or could affect many people, though not necessarily a specific customer.p: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions