Page Summary
-
The Google Code Scanner API enables code scanning without requiring camera permission, preserving user privacy by delegating the task to Google Play services.
-
It supports various code formats, returns a
Barcodeobject, and is ideal for apps needing seamless code scanning without a custom UI. -
Auto-zoom, available from version 16.1.0, automatically zooms in on barcodes, eliminating the need for manual adjustments and making scanning faster and more accurate.
-
The API uses an unbundled library downloaded before use and requires Android API level 21 or higher.
-
For complex use cases requiring a custom UI, the ML Kit Barcode Scanning API is recommended.
The Google code scanner API provides a complete solution for scanning code
without requiring your app to request camera permission, while preserving user
privacy. This is accomplished by delegating the task of scanning the code to
Google Play services and returning only the scan results to your app (Video 1).
All image processing occurs on the device and Google doesn't store the results
or image data. The API supports the same code formats as the
ML Kit Barcode Scanning API and returns the
same Barcode
object.
This API is ideal for apps that require seamless code scanning without the need for a custom UI or camera experience. The implementation resides entirely within Google Play services, ensuring minimal impact on the size of your app.
Starting with version 16.1.0, you can enable auto-zoom to allow the Google code scanner to automatically scan barcodes that are far away from the camera. When users point their devices at a barcode, the scanner will intelligently detect and zoom in on the barcode. This eliminates the need for manual zoom adjustments, making barcode scanning faster, more accurate and more accessible (see Video 2).
![]() |
![]() |
| Video 1. Google code scanner integration | Video 2. Auto-zoom effect |
For more complex use cases that require a custom UI, we recommend using the ML Kit Barcode Scanning API directly.
If you have questions, want to submit a bug, or need assistance, check the ML Kit community page.
Before you begin
To prepare your app, complete the steps in the following sections.
Configure your app
In your top-level
settings.gradlefile, include Google's Maven repository and Maven central repository in under thedependencyResolutionManagementblock:dependencyResolutionManagement { repositories { google() mavenCentral() } }Add the Google Play services dependency for the
play-services-code-scannerSDK to your module's Gradle build file, which is commonlyapp/build.gradle:

