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.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store