How to Add an Android Barcode Scanner Library

| Developers

Android phone with Scandit Android barcode scanner library being used to scan a barcode on a package.

Integrating a barcode scanner into your Native Android app isn’t as easy as you think.

It requires more than setting camera permissions and capturing camera images. You also need to consider UX and performance principles.

Here’s a familiar development scenario: you’re creating a Native Android application, a journey of long days and unending bugs, and there’s a nagging thought at the back of your mind. The app’s barcode scanning functionality – a small but critical part of your app – will inevitably face testing by real users in real-world situations you hadn’t considered. You have no idea whether the feedback will be good or bad, and the team’s focus is taken up by other features.

The trick to choosing the right barcode scanner library for your app and avoiding common barcode scanning challenges is understanding what barcode scanning users want, and what they need to make them productive in the long term.

Whether you’re a UX expert or not, this blog explains the key user and performance principles to successfully integrate an Android barcode scanner library into your Native Android app, including a step-by-step tutorial for the Scandit SparkScan Native Android barcode scanner SDK.

Why UX matters for Android barcode scanning

Integrating a barcode scanning library for Android is like trying to solve the platform’s hardware fragmentation issues. The complexity (often unexpected) can be overwhelming if you don’t have the tools or expertise to deliver the best user experience.

Happy users need more than a camera and event handler

While barcode scanning may seem easy, there can be significant downstream problems with user adoption if you don’t get navigation, interaction and feedback right.

Open-source options often require you to develop your own user interface (UI), incurring all the research, development, and testing costs. Paid libraries tend to include pre-built UI components that reduce your reliance on UX expertise and effort.

Understanding the UX workflows below will help you choose the best Native Android barcode scanner library for your application development.

Starting the scanning process

Android users don’t want to navigate through complex menus or switch between the app and a different interface when scanning barcodes. For enterprise apps in particular, an inconvenient and disconnected experience incurs job performance hits that can impact operations.

Good UX requires a seamless transition from the main application into scanning mode. The following video demonstrates how the Scandit SparkScan Native Android barcode scanner API enables users to swipe or tap a collapsed floating button to activate the scanner. It then provides a large, semi-transparent button to capture barcodes.

In-camera aiming assist

Aiming a smartphone camera is a difficult task in situations where the barcode is far away from the device, or when users must bend or lie down to scan packages in hard-to-reach placements.

It’s also challenging when packages have multiple barcodes printed on them. As a number of barcodes will be in the camera’s field of view at the same time, the user is forced to spend time aiming and selecting the right one.

Features like on-screen guides, visual hints, or even augmented reality (AR) overlays help users position the camera correctly.

Here are two examples of desirable in-app features:

  • A viewfinder to help the user understand that scanning is live and position the camera appropriately.
  • Restricting the scan area to help capture barcodes in cluttered areas. This also improves performance on low-end Android devices.

Strong and clear feedback

Your Android app should provide immediate and unambiguous feedback on the success or failure of a barcode scan. A delayed or confusing response leads to user frustration, especially in loud environments or locations where it’s hard to see the device’s screen.

Helpful feedback mechanisms include visual and auditory cues such as:

  • Drawing a symbol, like a brush overlay, at the location of the detected barcode to confirm that your app scanned the intended item.
  • Playing a sound and vibrating the device when the scanner performs a capture.

Supporting different scan modes

Allowing users to choose between single scans and continuous scanning modes helps them adapt to different situations where the number or configuration of barcodes varies (such as a warehouse or retail store).

SparkScan has two modes built into its Native Android barcode scanner SDK:

  • Single scan: the user triggers the scanner for every barcode, providing greater control over the scanning experience.
  • Continuous scan: The user triggers the scanner once and the app scans multiple barcodes without further interaction, reducing user fatigue.

Start barcode scanning on Native Android

Add enterprise-class barcode scanning in minutes with SparkScan.

Try for free

Ensuring your Android barcode scanner API is ready for the real world

An open-source Android barcode scanner library that’s hard to use or slow to scan may be sufficient if you’re scanning at a low frequency. However, it’s likely not best suited for an environment such as a  warehouse processing thousands of items daily.

Here are some considerations to think about when selecting your scanner SDK.

1. Scanner performance

Whether deployed in an enterprise or commercial environment, you should consider and measure against the following performance requirements:

  • Accuracy: Relying on barcode scanning for inventory management, asset tracking, quality control, and similar operations requires a barcode scanning library that ensures the right items are selected, picked, and tracked.
  • Speed: A barcode scanning library that captures and processes images fast means faster business operations.
  • Field-of-view and distance: Scanners often have to deal with barcodes on objects of various sizes, shapes, and distances from the device.
  • Handling tough barcodes: A barcode may be torn, partially obscured, wrapped in plastic, or reflecting light to cause camera glare – your library should be able to handle all these conditions.
  • Capturing multiple barcodes simultaneously: Employees may need to scan multiple barcodes at once or in quick succession, such as a worker in a fulfillment center required to scan a product barcode and a location barcode fast to meet shipping times.

2. Low-light situations

In many settings, lighting conditions can vary widely between dark to brightly lit. Your Android barcode scanner should perform well in low-light or no-light situations, such as stockrooms, back-of-store areas, and nighttime delivery routes.

3. Large device fleets with diverse models

Enterprises often have a diverse fleet of Android-based employee devices – especially in Bring-Your-Own-Device (BYOD) situations – with different camera specifications and processor architectures.

Your barcode scanner library must be compatible with a wide range of Android devices, ensuring employees have a consistent user experience and avoiding the need to retrain on every new device. (You can see SparkScan’s system requirements here.)

4. Support for different Android development frameworks

For developers using a cross-platform development framework, check that your barcode scanner library supports it. The Scandit SDK is also available for Cordova, Xamarin (iOS, Android, and Forms), .NET (iOS and Android), React Native, Flutter, Capacitor, and Titanium.

Enterprise-ready: The Scandit SparkScan Android barcode scanner API

SparkScan, part of the Scandit Smart Data Capture Platform, allows developers to add pre-built and intuitive barcode scanner capabilities to any Android (or iOS) smartphone app.

The SparkScan Native Android barcode scanner SDK is built upon well-researched UX principles and optimized through feedback from thousands of customers across various environments. Its key feature is a pre-built scanning interface that floats on top of any Android app, reducing your development time and solving many common scanning pitfalls for you.

The interface is customizable for different needs – for example, options to provide audio or haptic feedback, the choice of triggering scans using a phone’s physical button, and scanning in left-handed mode.

Graphic showing the three steps of Scandit’s scanning UI/UX framework for adding a barcode scanning library to an Android app.

Just how easy is it to integrate SparkScan into your Android app? The next sections explain how to implement a customizable Android barcode scanning interface in just a few steps.

Get started with SparkScan for Native Android

The fastest way to see if SparkScan will work for you is to run one of our Android barcode scanning examples from GitHub on your development device.

Follow these steps to add the pre-built SparkScan features to your app:

  1. Add the SparkScan SDK to your project.
  2. Create a new Data Capture Context instance.
  3. Configure the SparkScan Mode.
  4. Setup the SparkScan View.
  5. Register the listener to be informed when a new barcode is scanned.

The prerequisites for these steps are:

  • The latest stable version of the Android SDK (for example, through the latest Android Studio).
  • An Android project with target SDK version 23 (Android 6, Marshmallow) or higher.
  • A valid Scandit Data Capture SDK license key. You can sign up for a free test account at

1. Add the SparkScan SDK to your project

Before setting up SparkScan, you need to obtain a valid Scandit Data Capture SDK license key:

  1. Sign up or sign in to your Scandit account.
  2. Create a project.
  3. Create a license key by specifying your bundle ID.

(If you already have a paid subscription, contact for a new license key.)

The Scandit Data Capture SDK is distributed as AAR libraries in the official Scandit maven repository.

You will always need to add a reference to com.scandit.datacapture:core, which contains the shared functionality used by the other data capture modules.

To add SparkScan barcode-related functionality, add a reference to com.scandit.datacapture:barcode (the ScanditBarcodeCapture API)

Other dependencies (ScanditParser API, ScanditTextCapture API, ScanditIdCapture API) are also available, but if you’re not using their specific features, you don’t need to worry about them.

1. To add SparkScan using Gradle

Add mavenCentral() repository to the build.gradle file:

repositories {

Add the necessary artifacts as dependencies to the app’s build.gradle as required:

dependencies {
  implementation "com.scandit.datacapture:core:[version]"
  implementation "com.scandit.datacapture:barcode:[version]"

Note that the core module depends on okhttp version 4.9.2. If your project already implements a different version of okhttp (within the supported version range specified in the requirements page), make sure to exclude the group from the Gradle implementation of the core module:

implementation("com.scandit.datacapture:core:[version]") {
  exclude group: "com.squareup.okhttp3"

2. To add SparkScan using Maven

Add the mavenCentral repository to the pom.xml file:

    <name>Maven Central</name>

Add the necessary artifacts as dependencies as required:


3. Additional steps

If you’re using the androidx.fragments dependency and experience a situation where a scanning fragment navigates to another scanning fragment with an incompatible mode, make sure you’re using version 1.3.0+ of the dependency. If not, you may run into an incompatible modes error, as the new fragment gets resumed before the previous is paused and for some time, incompatible modes may be enabled in the DataCaptureContext simultaneously. This leads to empty results in sessions.

The Scandit SDK uses content providers to initialize scanning capabilities. If your content providers depend on the Scandit SDK, choose an initOrder lower than 10 to make sure the SDK is ready first. If not specified, initOrder is zero by default and you have nothing to worry about.

For more information, read the official Android <provider> documentation.

Camera permissions for Android: When using the Scandit Data Capture SDK, you must set the camera as the frame source for barcode, text, and label capture. To do this, you must request camera permissions in your application before starting scanning. To see how to achieve this, take a look at our samples.

2. Create a new Data Capture Context instance

The next step to add barcode scanner capabilities to your Android application is to create a new Data Capture Context. The context expects a valid Scandit Data Capture SDK license key during construction.

DataCaptureContext dataCaptureContext = DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");

3. Configure the SparkScan Mode

The SparkScan Mode is configured through SparkScanSettings, allowing you to register one or more listeners that are informed whenever a new barcode is scanned.

For this blog, we set up SparkScan for scanning EAN13 codes. Change this to the correct symbologies for your use case (for example, Code 128, Code 39…).

SparkScanSettings settings = new SparkScanSettings();
HashSet symbologies = new HashSet<>();

Next, create a SparkScan instance with the settings initialized in the previous step:

SparkScan sparkScan = new SparkScan(settings);

4. Setup the SparkScan View

The SparkScan built-in user interface includes the camera preview and scanning UI elements. These guide the user through the scanning process.

The SparkScanView appearance can be customized through SparkScanViewSettings.

SparkScanViewSettings viewSettings = new SparkScanViewSettings();
// setup the desired appearance settings by updating the fields in the object above

By adding a SparkScanView, the scanning interface (camera preview and scanning UI elements) is added automatically to your application.

Next, add a SparkScan View to your view hierarchy by constructing a new SparkScan view. The SparkScan view is automatically added to the provided parentView (preferably an instance of SparkScanCoordinatorLayout):

SparkScanView sparkScanView = SparkScanView.newInstance(parentView, dataCaptureContext, sparkScan, viewSettings);

Additionally, make sure to call sparkScanView.onPause() and sparkScanView.onResume() in your Fragment/Activity onPause and onResume callbacks. You have to call these for the correct functioning of the SparkScanView.

protected void onPause() {

protected void onResume() {

5. Register the listener to be informed when a new barcode is scanned

To keep track of the scanned barcodes, implement the SparkScanListener interface and register the listener to the SparkScan mode.

// Register self as a listener to monitor the SparkScan session.

SparkScanListener.onBarcodeScanned() is called when a new barcode is scanned. This result is retrieved from the first object in the provided barcodes list: SparkScanSession.newlyRecognizedBarcodes. Note that this list only contains one barcode entry.

When a barcode is scanned, it is possible to emit a sound and visual feedback using SparkScanView.emitFeedback() as follows:

public void onBarcodeScanned(
    @NonNull SparkScan sparkScan, @NonNull SparkScanSession session, @Nullable FrameData data
) {
    // Gather the recognized barcode
    Barcode barcode = session.getNewlyRecognizedBarcodes().get(0);

    // Emit sound and vibration feedback
    sparkScanView.emitFeedback(new SparkScanViewFeedback.Success());

    // This method is invoked from a recognition internal thread.
    // Run the specified action in the UI thread to update the internal barcode list.
    runOnUiThread(() -> {
        // Update the internal list and the UI with the barcode retrieved above
        this.latestBarcode = barcode

Testing barcode scanning performance on Android

The best way to test a potential Android barcode scanning API is to try it out in the real world. Whether you installed SparkScan or another barcode scanning library, here are several performance-testing questions to ask yourself:

  • Is there clear guidance, feedback, and helpful hints to foster a smooth workflow rather than a confused, error-prone activity?
  • Can you scan barcodes in different orientations, such as upside down and sideways? Flip the phone upside down to see how the scanner performs.
  • Can you scan barcodes with reflections and glare?
  • Can you scan barcodes at a distance? Are you able to zoom in if needed?
  • Do you receive scanning feedback in loud environments and while wearing headphones?

You can also use our barcodes sample sheet for quick evaluation.

Get your enterprise-proven Native Android barcode scanner SDK

Prioritizing UX when selecting and implementing an Android barcode scanner library makes your life easier. Simplified usage, fewer user frustrations, and rapid adaptability to growing business demands pave the way toward increased adoption and productivity.

Interested in how SparkScan turns Android smartphones into intuitive, ergonomic scanners with minimal integration time? Sign up for our free 30-day test SDK now.