android / android/camera-samples
Camera2 Basic - NullPointerException
- Dominant language
- Kotlin
- Stars
- 5.5k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
The second time I try to take photo the sample app crashes with the next error:
```
2022-04-01 16:38:36.235 9849-9849/com.android.example.camera2.basic E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.example.camera2.basic, PID: 9849
java.lang.NullPointerException
at com.example.android.camera2.basic.fragments.CameraFragment.getFragmentCameraBinding(CameraFragment.kt:79)
at com.example.android.camera2.basic.fragments.CameraFragment.access$getFragmentCameraBinding(CameraFragment.kt:74)
at com.example.android.camera2.basic.fragments.CameraFragment$animationTask$2.invoke$lambda-1$lambda-0(CameraFragment.kt:117)
at com.example.android.camera2.basic.fragments.CameraFragment$animationTask$2.lambda$kSaIYQrPru2VxvpYHL5tPwU4w3s(Unknown Source:0)
at com.example.android.camera2.basic.fragments.-$$Lambda$CameraFragment$animationTask$2$kSaIYQrPru2VxvpYHL5tPwU4w3s.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
```
So it takes photo with success only for the first time
Android 30+ tested devices
Contributor guide
Research direction
Start in CameraFragment.kt at getFragmentCameraBinding on line 79 and the animationTask code around line 117. Reproduce taking a photo twice on an Android 30+ device, then trace why the binding is null during the second capture. Done means the sample app captures a second photo without the reported NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100