how to import ZXING library in android application?
Solution 1
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.
Solution 2
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
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
Solution 3
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.
Related videos on Youtube
krishna5688
Updated on April 13, 2020Comments
-
krishna5688 about 4 years
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?
-
krishna5688 over 12 yearsThank you for your reply. the first line of the link you provided says that "If the Barcode Scanner is installed on your Android device, you can have it scan for you and return the result " , But I need to consider scenario where zxing barcode application is not already installed on android device. I don't want to force user to install barcode scanner saperately.
-
krishna5688 over 12 yearsIt may sound foolish for you, but can you please provide me any steps to compile /core and creating core.jar file. I am using eclipse IDE for developing this application. If you have any link containing steps for it then please share it.
-
Archit over 12 yearsTry this link...code.google.com/p/zxing/wiki/DeveloperNotes That way you can integrate it as a part of your app. There is also a way of checking if an application is present on your upon installation and at runtime as well...I can't recollect those now, so Google is your friend.
-
Archit over 12 years@krishna5688: Word of advice...read up the wiki on the ZXing site before asking questions on StackOverflow. A lot of what you are asking is already present on the wiki. The StackOverflow community is always more responsive to a specific query. It's hard for someone to outline everything for you here.
-
Sean Owen over 12 yearsErm, just run "ant" in the core/ directory.