我正在尝试使用QRGen library
生成QRCode图像。
我已将qrgen-1.0.jar
文件导入我的项目。
我知道这个问题是重复的。 我已通过此link
引用了以下代码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;
}
但是我收到以下错误。
04-24 11:48:57.138: E/AndroidRuntime(824): FATAL EXCEPTION: main
04-24 11:48:57.138: E/AndroidRuntime(824): java.lang.NoClassDefFoundError: net.glxn.qrgen.QRCode
04-24 11:48:57.138: E/AndroidRuntime(824): at com.example.barcodeexample.QRCodeGeneratorActivity.onCreate(QRCodeGeneratorActivity.java:34)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.Activity.performCreate(Activity.java:5008)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.os.Looper.loop(Looper.java:137)
04-24 11:48:57.138: E/AndroidRuntime(824): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-24 11:48:57.138: E/AndroidRuntime(824): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 11:48:57.138: E/AndroidRuntime(824): at java.lang.reflect.Method.invoke(Method.java:511)
04-24 11:48:57.138: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-24 11:48:57.138: E/AndroidRuntime(824): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-24 11:48:57.138: E/AndroidRuntime(824): at dalvik.system.NativeStart.main(Native Method)
我已导入
import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;
答案 0 :(得分:1)
2.0-SNAPSHOT应该解决这个https://oss.sonatype.org/content/repositories/snapshots/net/glxn/qrgen/android/2.0-SNAPSHOT/
答案 1 :(得分:0)
最后,我找到并关注了适合我的事情。
认为这可能对像我这样的人有所帮助。
感谢。