CameraX on Android Fragment in Kotlin with ImageAnalyzer

CameraX is a relatively new Camera API in Android. Unlike the predecessors, CameraX is easy to use and requires less tweaking in order to adopt a Camera View in your application. Since, in the official sample code, Google made it a little buggy (for good intentions though) and they only implement it on Activity. So in this article, I’ll go over how to make implement CameraX using Fragment and mention some of the points we should be caution with.

1. Importing CameraX project in Gradle.