[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:
- From CropImageActivity, select Camera option
- Accept permissions if needed
- Take photo
- Accept Photo
- CropImageActivity is cancelled, NPE reported above is thrown.
Expected behavior
- From CropImageActivity, select Camera option
- Accept permissions if needed
- Take photo
- Accept Photo
- 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:
- Created 3 years ago
- Reactions:1
- Comments:22 (11 by maintainers)
Top GitHub Comments
@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 =)After the latest version 2.1.1, the problem has been resolved for me. I used device: Emulator, Pixel 3a Operating System: API 30.