Barcode Scanner with CameraX and MLKit

Barcode and Android icons made by Freepik from



1. CameraX

The Setup

implementation "$camerax_version"
implementation "$camerax_version"
implementation ""
apply plugin: 'kotlin-android-extensions'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

The View

The Code

This will change a little later, but it’s enough for the camera to start streaming into the view.

2. MLKit

The Setup

implementation ''

The Code

typealias BarcodeListener = (barcode: String) -> Unit

3. Connecting the Parts

cameraExecutor = Executors.newSingleThreadExecutor()

Passionate Android developer with tons left to learn.