Search code examples
androidandroid-studiozxingbarcode-scannerlibs

creating barcode scanner with zxing source code and core java


I am assigned to create a barcode scanner which wont make user install any third party app.

My ADT is Android Studio 2.0, SDK 24.4.1, jdk edition 8.

My target was to copy the zxing source and keep it with my app source and copy the core to the libs folder of zxing source. Then in the MainActivity of my app source I called CaptureActivity from Zxing package to create the app. It is not working & now I am confused...

Those what I did...

  1. I created a project named "BarcodeScanner" and with a blank activity.
  2. I downloaded zxing barcode scanner source code 4.7.5 zip file and after extraction I copied it to the project as a directory. (Note: It is a different package, different than my app package)
  3. Everything seems ok, no error. Then I downloaded core-3.2.1.jar to the libs folder, created library dependency of the app on the core and built the project and core is compiled.
  4. Everything ok but ONE SINGLE PROBLEM when in case of MainActivity of my BarcodeScanner app project when I go to set CaptureActivity as onClick action of button of MainActivity Layout, CaptureActivity class cannot be found as it is not in the core.

Is there any way to work with zxing library in Android Studio??? It kept me stuck for days...


Solution

  • Use this version of zxing instead

    https://github.com/journeyapps/zxing-android-embedded

    • it have capture activity merged in actual project.
    • Integration is easier than actual zxing project.
    • Library size is small so it will reduce overall apk size.
    • No need to get confused between which jar to add, only jar dependency is core 3.2 library which you can get from here .
    • If you are using eclipse you can get eclipse version here

    https://github.com/hiteshsahu/XZing-Barcode-Scanner-Minified-Eclipse