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.

Crash while navigating back to preview from captured image

See original GitHub issue

Getting this error when running the sample.

Steps to reproduce.

  1. Capture the photo.
  2. Navigate to captured image on clicking Gallery icon.
  3. Navigate back to camera preview and notice the crash

I am able to reproduce consistently 👍

Device Name : Nokia 5.1 Model : TA-1061 Android version : 9

    Process: com.android.example.cameraxbasic, PID: 31287
    java.lang.IllegalStateException
        at androidx.core.util.Preconditions.checkState(Preconditions.java:96)
        at androidx.core.util.Preconditions.checkState(Preconditions.java:108)
        at androidx.camera.camera2.internal.Camera2CameraImpl$StateCallback.onClosed(Camera2CameraImpl.java:1298)
        at androidx.camera.camera2.internal.CameraDeviceStateCallbacks$ComboDeviceStateCallback.onClosed(CameraDeviceStateCallbacks.java:105)
        at android.hardware.camera2.impl.CameraDeviceImpl$5.run(CameraDeviceImpl.java:207)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.os.HandlerThread.run(HandlerThread.java:65)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Simon-Richardscommented, Feb 25, 2020

I was getting this error also, and on screen rotation too. I did as @waliahimanshu suggested and upgraded to -alpha09 and the issue is gone

1reaction
waliahimanshucommented, Feb 6, 2020

Hi, just took the latest changes since yesterday, and got the crash using repro steps above but different stack trace (see below).

However, yesterday I updated the version of sample project to alpha09, and the crash did not happen. I also found this note in release notes of alpha 09

Fixed issues when closing then opening cameras resulting in “Precondition” check failure.

So I reckon, the sample needs updating, because as is it crashes constantly.

2020-02-06 12:05:12.428 16038-16038/com.android.example.cameraxbasic D/AndroidRuntime: Shutting down VM
2020-02-06 12:05:12.429 16038-16079/com.android.example.cameraxbasic D/Camera: releasing session in state CLOSING
    
    --------- beginning of crash
2020-02-06 12:05:12.430 16038-16038/com.android.example.cameraxbasic E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.android.example.cameraxbasic, PID: 16038
    java.lang.NullPointerException: No camera bound to use case: ImageAnalysis:androidx.camera.core.ImageAnalysis-55973804-64fa-4cf8-b704-ddc45daef628
        at androidx.core.util.Preconditions.checkNotNull(Preconditions.java:81)
        at androidx.camera.core.UseCase.getBoundCameraId(UseCase.java:360)
        at androidx.camera.core.UseCase.isCurrentlyBoundCamera(UseCase.java:371)
        at androidx.camera.core.ImageAnalysis$1.onError(ImageAnalysis.java:212)
        at androidx.camera.camera2.internal.Camera2CameraImpl$16.run(Camera2CameraImpl.java:1008)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6715)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)```
Read more comments on GitHub >

github_iconTop Results From Across the Web

Preview crashes when i try to view images full screen???
When i want to view a photo in Preview in "full screen", like i should be able to, the whole app crashes, shuts...
Read more >
android - App is crashing after capturing picture using intents
Solution: Save the file path of the Image and use it when onActivityResult is called. You can use onSavedInstanceState and onRestoreInstanceState methods to ......
Read more >
Android app CRASH when capturing image using camera ...
Steps to Reproduce After successfully capturing an image using camera, when i click OK, the app crashes saying 'Unfortunately ** Stopped'.
Read more >
[Camera Plugin] Application crashes and restarts when taking ...
When capturing an image with the Camera plugin it crashes everytime I take a picture and the app restarts. This only happens on...
Read more >
How to Solve Windows 10 Photos App Crashes Effectively[2021]
Click 'Windows' + 'E' keys to launch 'Windows Explorer. · Seeing the 'Libraries' folder, you got to choose this. · The right window...
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