Create a Preview Use Case. | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7005190-camerax-getting-started/lessons/4

Hi @aldominium ,

Thanks for a great little preview, however the app keeps crashing if you close it and open it again a second time (it works fine on a fresh install, and allowing camera permissions).

The error is java.lang.IllegalStateException: textureView.display must not be null

So it turns out you need to add textureView.post { bindCamera() } to the requestCameraPersmissionResult (it was previously just bindCamera()), if you have already accepted the permissions, the next time you restart the app, it seems it is trying to bindCamera → updateTextureView before the view is ready.