Advanced Topics

Common Errors

Blank Screen instead of Camera Preview

The PreviewView of CameraX works by outputing the camera preview image to the background of its surface.

Any main theme (the android:theme attribute for the <application> tag) that sets the android:background value will overwrite the background of the PreviewView.

<!-- DO NOT DO THIS ON THE MAIN THEME -->
<!-- IT WILL OVERWRITE THE CAMERA PREVIEW -->
<item name="android:background">@color/background</item>

If you have the 'Blank Screen' issue and have already requested the camera permissions, remove this line and the camera preview should be displayed normally.