About comics barcodes, ZXing and Android Studio

A few days ago I was trying to use my Android phone to scan some comics barcodes of my collection. I thought it was easy, but I soon found out that none of the apps I tried was able to properly get them. Let’s see why and what I could do…

comics barcodes

The comics barcode jungle

My statement in the previous paragraph is not completely accurate. I was able to properly scan the barcodes of my comics book, while it wasn’t possible to get those of the comics magazine, e.g. the periodical ones (at least in Italy!).

Looking at the barcodes, there’s an outstanding difference. This is the barcode of a comics book:

Comic book barcode

while this is the barcode of a comics magazine:

As you can see, this last one is composed of two parts: the various apps I tried were able to get just the first part of the barcode, while the latter was not recognized.

So, I tried to educate myself on the topic: there are many resources on the internet, but one of the best articles is here, which I suggest reading to understand how those barcodes are composed.

Summarizing a lot, in Italy a comic magazine code is composed of two parts: the first one is in format EAN-13, while the second one is in format EAN-5 Addon, something that as a stand-alone barcode does not have any meaning.

Now that the theory is clear, the plan is simple: I have to find an app that is capable of managing barcodes in EAN-13 with an EAN-5 Addon. But, maybe my fault, I was not able to find any…

The Android ML Kit and ZXing

I am a fan of DIY. Therefore, I looked for libraries I could use to create a simple app, despite of being completely in the dark about modern Android apps development.

Nowadays, the standard way of decoding barcodes in Android seems to be the ML kit, for which there’s also an example application. However, EAN-5 Addon is not among the supported formats (also verified with the test application). And it’s not also clear if there’s the possibility to submit a feature request for this project.

Before ML there was ZXing, an open-source, multi-format 1D/2D barcode image processing library implemented in Java. I’ve written “was”, because the project is currently in maintenance mode. As the Readme states, “the Barcode Scanner app can no longer be published” (not completely sure about the reason for this).

However, quickly looking at the source code, I found that ZXing seems properly supporting the EAN-5 Addon. This makes it the ideal candidate for solving my need. There’s also a sample app that could make my life easier, but I did not consider my lack of knowledge in this field…

ZXing and Android Studio

Driven by this discovery, I downloaded the latest Android Studio (Flamingo), and tried building the code after importing the project directly as it is in the git repo. Unfortunately, no luck, due to many different errors.

As written previously, I’m not familiar with Android Studio and app development, but I thought that having the example barcode scanner application running would have been more straightforward. For sure my lack of knowledge is the primary cause for the issues I had faced. In fact, it took me several hours to make-up things for having something capable to run in my Android 13 phone.

So far, I’m not even sure that I really made everything properly (actually I’m pretty sure that I didn’t). I’ll detail what I did to get my comics barcodes scanner app in the next blog post, providing also a github repo with the modified code, so that anyone can build that app for a modern Android system without too much effort.