Skip to content

ML Kit barcode scanning (Android)

Recognize and decode barcodes (QR, EAN, PDF417, etc.) on-device with ML Kit.

Source

Install options

ModeGradle dependencyTrade-off
Bundledcom.google.mlkit:barcode-scanning:17.3.0+~2.4 MB, instant model
Play Servicescom.google.android.gms:play-services-mlkit-barcode-scanning:18.3.1+~200 KB, may download on first use

Requires minSdkVersion 23+. Add Google Maven to project build.gradle.

Basic usage pattern

  1. Build InputImage from CameraX, Bitmap, or byte buffer
  2. Create BarcodeScanner via BarcodeScanning.getClient()
  3. Call process(image) and handle List<Barcode> (format, raw bytes, corner points)

For simple QR-only flows, Google’s Code Scanner API may be faster and permission-light.

Image quality

  • Smallest barcode unit should be ≥ 2 pixels wide (2D: 2 px tall)
  • EAN-13 ideally ≥ 190 px wide; dense PDF417 needs more resolution

Curated technical notes — open source on GitHub