In this tutorial, we will learn to integrate ZXing lib into an Android app. Let us first get some idea about ZXing.


ZXing (“zebra crossing”) is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages. ZXing is also hosted under Google Open Source Project.

The latest version up to this date is 3.3.3. Modules in this release we need to focus on are –

The core image decoding library, and test code (Java lib)
Android app also available on Play Store Barcode Scanner
Android-related code shared among android, other Android apps
Supports integration with Barcode Scanner via Intent

All the modules are available on Maven Central –



Let’s say we want to integrate ZXing in our app called QR Code Scanner Android. Now the problem is that android module is actually an Android application and not an Android library. So to use the ZXing lib as advocated by ZXing themselves, we have the following options –

Obviously, both these options depend upon the Barcode Scanner app. So to overcome this dependency JourneyApps has come up with ZXing Android Embedded which is loosely based on the ZXing Android Barcode Scanner application but an with the official ZXing project.

ZXing Android Embedded is available on bintray –

ZXing Android Embedded

So this tutorial is based on integrating the ZXing Android Embedded library in our QR Code Scanner app. You can find the source code of this tutorial on QR Code Scanner. Let’s start the integration. From version 3.6.0, only Android SDK 19+ is supported by default.


repositories {  

dependencies {  
   implementation 'com.journeyapps:zxing-android-embedded:3.6.0'

For Android 14+ support, see this link.



class MainActivity : AppCompatActivity() {     
   override fun onCreate(savedInstanceState: Bundle?) {        
         button_scan_qr_code.setOnClickListener {
     override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        val result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data)
        if (result != null) {
            if (result.contents == null) {
                Toast.makeText(this, "Cancelled", Toast.LENGTH_LONG).show()
            } else {
                Toast.makeText(this, "Scanned: " + result.contents, Toast.LENGTH_LONG).show()

On click of button_scan_qr_code, CaptureActivity will start scanning using default camera. Once it scans any QR code, it sends back the result to onActivityResult the MainActivity.

ZXing also provides online QR Code Generator. Enter the required fields, generate and scan it to get the results.

ZXing Android Embedded lib also provides various customization –

For more advanced options do have a look at their Sample application.

That’s it for this tutorial. Thanks to the ZXing authors for Java library and ZXing Android Embedded to make this integration easy. Enjoy scanning the QR code. ????

Do you have any product idea or business need?

Omnivore POS integration - Ensuring Agility To Your Restaurant Businesses

Omnivore POS integration - Ensuring Agility To Your Restaurant Businesses

Omnivore software offers a point-of-sales integration API making the restaurant system agile, more customer engaging and adaptive to fast changing business environments.

Unit Testing using Mockk.io

Unit Testing using mockK.io in Kotlin

Learn about unit testing using mockk.io in Kotlin.

Apples In-App Purchase

Hands-On Implementation of Apple’s In-App Purchases On Ruby Based Server

Information about Languages & Tools, Server Configuration and Endpoint & API Setup and many more.