简体   繁体   中英

how to import ZXING library in android application?

I need to implement ZXING QR code scanner in my application. I have complete source code for ZXING Android. Now, I want to use this in my application. my question is that should I copy all ZXING library code in my application including manifest,xml and java files or I can have a jar file which I need to just add in my application? Can anybody tell me how to create jar file from android code, or is any ZXING jar already available which I can just include in my application?

http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/

Thats a step by step guide to natively integrating. It integrates the zxing project into yours as a backup of sorts. You will send out an intent request, but your application is registered as a receiver of that request. If the user doesn't have a different scanner, yours will be the only option. If they have other scanners it will allow the user to choose. If you want your app to always be chosen without another option, the comments in the tutorial detail how to change the intent filter to do it.

Keep in mind this is the quick and dirty way to do it. As others have mentioned, ZXing provides a great tutorial on how to send a barcode intent out and point them to the market if they don't have a scanner.

In Zing library you only need the android/ and the core/ projects . ZXING library code doesn't have core.jar file. You have to create core.jar file manually from the command line only (can be a ​bit tricky) so download core.jar alone from this link

core.3.2.0 download

then need to add the core.jar file into our project.

add this dependency in app level gradle

'com.google.zxing:core:3.2.0'

REFERENCE site

Integrate zxing barcode

QR code using ZXing library

If all you need to do is scan a barcode...then you can simply do it via intents. Check this page for a tutorial on scanning via intents.

There is a project in github which was embedded in an android application and it is compatible as android studio project;

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

If you live a problem about gradle when you run above project, you can use below project which is same project but there is not any issue about gradle file;

https://bitbucket.org/_oguzhan/ocrandroid

You would never want to copy the android/ code completely. If anything, you want to compile the core/ code, and place the resulting core.jar in your project's libs/ folder. Then, you have access to the core scanning code in your project.

But, it is far easier to integrate via Intent as Archit says.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM