本文介绍了使用QRGen库时的错误产生QR code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用QRGen库生成一个 ByteArrayOutputStream 的QR code和它的生成位图图像。

I am using the QRGen library to generate a ByteArrayOutputStream for a QR code and the generate a Bitmap image for it.

我已经导入了以下3个罐子到我的项目:

I have imported the 3 following jars into my project:


  • qrgen-1.0.jar

  • zxing核-1.7.jar

  • zxing-J2SE-1.7.jar

这是该方法生成QR code的ByteArray:

This is the method generating the QR code ByteArray:

public Bitmap qrBitmapFromString(String qrText){
    ByteArrayOutputStream out = QRCode.from(qrText).to(ImageType.PNG).withSize(300, 300).stream();
    byte[] data = out.toByteArray();
    Bitmap bmp = BitmapFactory.decodeByteArray (data,0,data.length, null);
    return bmp;
}

不过,我收到以下错误:

But I am getting the following error:

03-05 12:39:31.089: E/AndroidRuntime(1479): FATAL EXCEPTION: main
03-05 12:39:31.089: E/AndroidRuntime(1479): java.lang.NoClassDefFoundError: java.awt.image.BufferedImage
03-05 12:39:31.089: E/AndroidRuntime(1479):     at com.google.zxing.client.j2se.MatrixToImageWriter.toBufferedImage(MatrixToImageWriter.java:48)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at com.google.zxing.client.j2se.MatrixToImageWriter.writeToStream(MatrixToImageWriter.java:75)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at net.glxn.qrgen.QRCode.stream(QRCode.java:99)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at co.emuze.emuzepay.PayCardFragment.qrBitmapFromString(PayCardFragment.java:27)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at co.emuze.emuzepay.PayCardFragment.onCreateView(PayCardFragment.java:23)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:795)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:998)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.BackStackRecord.run(BackStackRecord.java:622)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1330)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.Activity.performStart(Activity.java:4474)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.ActivityThread.access$600(ActivityThread.java:122)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.os.Looper.loop(Looper.java:137)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at android.app.ActivityThread.main(ActivityThread.java:4340)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at java.lang.reflect.Method.invokeNative(Native Method)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at java.lang.reflect.Method.invoke(Method.java:511)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-05 12:39:31.089: E/AndroidRuntime(1479):     at dalvik.system.NativeStart.main(Native Method)

什么原因呢?

推荐答案

2.0-SNAPSHOT工作得非常好于Android,并已成为在上周更快。一个例子可以在这里找到:

2.0-SNAPSHOT works very well on android and has become faster during the last week. An example can be found here: https://github.com/atomfrede/qrgen-android-example

这篇关于使用QRGen库时的错误产生QR code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 15:57