Skip to content

Camera fails to start on some devices, App throws Attempt to invoke virtual method 'void android.media.ImageReader.setOnImageAvailableListener(android.media.ImageReader$OnImageAvailableListener, android.os.Handler)' on a null object reference. #105200

Open

Description

@RobertApikyan

Camera won't start on Xiaomi POCO X4 Pro 5G device, it fails to start the example application from the library.

Error

Attempt to invoke virtual method 'void android.media.ImageReader.setOnImageAvailableListener(android.media.ImageReader$OnImageAvailableListener, android.os.Handler)' on a null object reference.

Steps to Reproduce

Flutter version 2.8.0
Camera version 0.9.7+1

1. I'm running the example from the library.

Screen Shot 2022-06-02 at 11 25 07

2. After clicking on the back camera, it displays the error message.

Screen Shot 2022-06-02 at 11 22 35

Activity

  1. maheshj01 commented on Jun 2, 2022

    @maheshj01
    Member

    see #29116

  2. danagbemava-nc commented on Jun 2, 2022

    @danagbemava-nc
    Member

    Hi @RobertApikyan, I run the camera example code on a Poco X3 NFC and the camera starts as expected. Is this the only device you're experiencing this issue on?

    Also, you appear appear to be on an older version of flutter. Can you try upgrading to the latest version of flutter to see whether or not you still experience this issue?

    Thank you

    video
    video_2022-06-02_08-56-32.mp4
  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2022
  4. RobertApikyan commented on Jun 2, 2022

    @RobertApikyan
    Author

    @maheshmnj thanks for quick response, you are right the exception is the same, but please pay attention that I'm running the original example application from the library, the same sample works perfectly for the other devices, but not for the Xiaomi POCO X4 Pro 5G. Unfortunately, In the issue #29116 I can not find the answer for my question.

  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2022
  6. RobertApikyan commented on Jun 2, 2022

    @RobertApikyan
    Author

    Hi @RobertApikyan, I run the camera example code on a Poco X3 NFC and the camera starts as expected. Is this the only device you're experiencing this issue on?

    Also, you appear appear to be on an older version of flutter. Can you try upgrading to the latest version of flutter to see whether or not you still experience this issue?

    Thank you

    video

    Hi @danagbemava-nc thanks for the answer, yes this seems only for the Xiaomi POCO X4 Pro 5G. Ok, I will update the flutter to the latest version and let you know about results.

  7. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2022
  8. RobertApikyan commented on Jun 2, 2022

    @RobertApikyan
    Author

    @danagbemava-nc I have upgraded the flutter version to 3.0.1, but the issue still exist, it displays the same error.

    Screen Shot 2022-06-02 at 13 41 41

  9. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2022
  10. danagbemava-nc commented on Jun 2, 2022

    @danagbemava-nc
    Member

    Hi @RobertApikyan, please provide the output of flutter run -v that captures the exception and the list of devices you have tested on and whether or not they reproduce the issue.

    Thank you

  11. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2022
  12. ManuverGujjar commented on Jun 2, 2022

    @ManuverGujjar

    Hi, I'm also facing the exact same issue on Redmi 11 Pro + 5G. even the Camera example app not working from pub.dev
    Other third-party camera apps are working fine on that device.

  13. RobertApikyan commented on Jun 2, 2022

    @RobertApikyan
    Author

    Hi, I'm also facing the exact same issue on Redmi 11 Pro + 5G. even the Camera example app not working from pub.dev Other third-party camera apps are working fine on that device.

    Same story, the latest version of the "camera awesome" library is working without any problem, however it seems abandoned, and the last update there was at Jun 2 of 2021.

  14. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 2, 2022
  15. 79 remaining items

  16. shivam-modi commented on Feb 25, 2023

    @shivam-modi

    Any updates to this issue, above suggested method fork the plugin is not working

  17. added a commit that references this issue on May 29, 2023
  18. singlapriyanka315 commented on Jul 19, 2023

    @singlapriyanka315

    When capturing image from back camera it is take 5-8 second to capture the image which is a lot but working fine for front camera and i am getting the following log.
    Slow Binder: BpBinder transact took 379 ms, interface=android.hardware.camera2.ICameraDeviceUser, code=1 oneway=false . D/Camera ( 6038): Updating builder with feature: FocusPointFeature
    D/Camera ( 6038): Updating builder with feature: ResolutionFeature
    D/Camera ( 6038): Updating builder with feature: SensorOrientationFeature
    D/Camera ( 6038): Updating builder with feature: FlashFeature
    D/Camera ( 6038): Updating builder with feature: ExposureOffsetFeature
    D/Camera ( 6038): Updating builder with feature: FpsRangeFeature
    I/Camera ( 6038): sending capture request
    11
    D/CameraCaptureCallback( 6038): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
    I/Camera ( 6038): unlockAutoFocus
    I/Camera ( 6038): refreshPreviewCaptureSession
    5
    D/CameraCaptureCallback( 6038): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
    I/Camera ( 6038): onImageAvailable
    2
    W/System ( 6038): A resource failed to call end.
    W/System ( 6038): A resource failed to call release.
    I/Camera ( 6038): CameraCaptureSession onClosed
    2
    I/Camera ( 6038): dispose
    I/Camera ( 6038): close
    2
    I/flutter ( 6038): Initialising connection
    W/BpBinder( 6038): Slow Binder: BpBinder transact took 342 ms, interface=android.hardware.camera2.ICameraDeviceUser, code=1 oneway=false
    I/Camera ( 6038): open | onClosed

  19. moved this to [PENDING] camera_android issues solved by camera_android_camerax in Android Camera Re-writeon Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolec: fatal crashCrashes that terminate the processp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    • Status
      [PENDING] camera_android issues solved by camera_android_camerax

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions