question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] - NPE when accepting a photo on Android 11

See original GitHub issue
  • 2.0.3

Describe the bug A user that opts to take a photo can capture a picture and upon accepting the photo (aka, tapping on the check mark) they are returned to destination that launched CropImageActivity.

What’s happening is an NPE is thrown (see below) when user accepts the photo, CropImageActivity.onActivityResult is called with resultCode == RESULT_CANCELED.

2021-02-10 09:45:14.860 6815-6815/? E/CAM_StateMachine: Failed to process event: com.android.camera.captureintent.event.EventTapOnConfirmPhotoButton@f96e55

2021-02-10 09:45:14.861 6815-6815/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.camera2, PID: 6815 java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:890) at com.google.common.base.Optional.of(Optional.java:103) at com.android.camera.captureintent.state.StateSavingPicture.onEnter(StateSavingPicture.java:77) at com.android.camera.captureintent.stateful.StateMachineImpl.jumpToState(StateMachineImpl.java:62) at com.android.camera.captureintent.stateful.StateMachineImpl.processEvent(StateMachineImpl.java:110) at com.android.camera.captureintent.state.StateOpeningCamera$9.onClick(StateOpeningCamera.java:307) at android.view.View.performClick(View.java:7448) at android.view.View.performClickInternal(View.java:7425) at android.view.View.access$3600(View.java:810) at android.view.View$PerformClick.run(View.java:28305) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

To Reproduce Steps to reproduce the behavior:

  1. From CropImageActivity, select Camera option
  2. Accept permissions if needed
  3. Take photo
  4. Accept Photo
  5. CropImageActivity is cancelled, NPE reported above is thrown.

Expected behavior

  1. From CropImageActivity, select Camera option
  2. Accept permissions if needed
  3. Take photo
  4. Accept Photo
  5. CropImageActivity proceeds to crop image

Screenshots N/A

Smartphone (please complete the following information):

  • Device: Emulator, Pixel 3a
  • OS: API 30

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:22 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
Canatocommented, Mar 5, 2021

@hlupico @gautamDev36 can you try on te latest 2.2.1 ?

If doesn’t work I finish to add 3 types of sample in the codebase, could you please try to replicate it on the sample code?

I will remove the pinned tag until we have answers =)

1reaction
kaanhangithubcommented, Feb 28, 2021

After the latest version 2.1.1, the problem has been resolved for me. I used device: Emulator, Pixel 3a Operating System: API 30.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.lang.NullPointerException: while take photo
When user denies the authorization, you cannot access the media files, you should use this code only if the authorization is accepted.
Read more >
Save Photo from Camera in Android, Fix NullPointerException
Save a picture to the SD Card from the camera in Android by using ANDROID_IMAGE_CAPTURE and Intent.putExtra. This also fixes a potential ...
Read more >
NullPointerException - Android Developers
Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking the length of null as...
Read more >
Accessing the Camera and Stored Media - CodePath Cliffnotes
Overview. This guide covers how to work with the camera and how to access media stored on the phone. Using the Camera. The...
Read more >
NullPointerException in BluetoothGatt.java ... - Issue Tracker
This issue has been seen (100% reproducable) on a Nexus 9 with Android 5.0.1 with an app that communicates with a BLE device....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found