[英]Android QR code generation with zxing library not working
Hi I am developing small android application in which I want to include Qr code functionality. 嗨,我正在开发小型Android应用程序,我想在其中包含Qr代码功能。 I downloaded zxing-2.1 and with the help of android project inside it and core.jar i create android library for android project.
我下载了zxing-2.1,并借助其中的android项目和core.jar来为android项目创建android库。 I created one android project and include that library into my android project.
我创建了一个android项目,并将该库包含到我的android项目中。
But when i tried to create one Qr code it gives me following error: 但是,当我尝试创建一个Qr代码时,出现以下错误:
// I tried to generate Qr code in following ways.
ImageView imageView = (ImageView) findViewById(R.id.qr_imageView);
String qrData = "nilkash";
int qrCodeDimention = 500;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrData, null,
Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimention);
try {
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
imageView.setImageBitmap(bitmap);
} catch (WriterException e) {
e.printStackTrace();
}
But It not recognizing QRCodeEncoder class. 但是它不能识别QRCodeEncoder类。 What i am doing wrong?
我做错了什么? Need help to generate Qr-codes with zxing library.
需要帮助以zxing库生成Qr码。 Thank you.
谢谢。
You didn't put core.jar
in your project's libs/
folder. 您没有将
core.jar
放在项目的libs/
文件夹中。 This is nothing to do with the library. 这与库无关。
EDIT: Oops, no, QRCodeEncoder
is actually a class in android/
, my fault. 编辑:糟糕,不,
QRCodeEncoder
实际上是android/
一个类,我的错。 It won't help to use core.jar
. 使用
core.jar
并没有帮助。 The problem is still of course that you're trying to use a class without making it accessible to your project. 当然,问题仍然在于您正在尝试使用一个类,而又无法将其用于您的项目。 This is not a library class though, but part of the app.
但是,这不是库类,而是应用程序的一部分。 You can reuse the source for this class in your app though, including copying it if that's easiest.
不过,您可以在应用中重用此类的源,包括在最简单的情况下复制它。
您可以在以下链接中找到core.jar http://repo1.maven.org/maven2/com/google/zxing/core/2.2/
QRCodeEncoder and Contents can be found here: QRCodeEncoder和内容可以在这里找到:
http://www.mysamplecode.com/2012/09/android-generate-qr-code-using-zxing.html http://www.mysamplecode.com/2012/09/android-generate-qr-code-using-zxing.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.