We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I'm trying to create a qrcode scanner for Android but it doesn't work. I've tried with 2 different librairies, com.cage.zxing4p3 (zxing4p3) and qrcodeprocessing. Here are the issues when I'm trying to decode it :
With zxing4p3 :
FATAL EXCEPTION: Animation Thread
Process: processing.test.lycee_loth, PID: 18058
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/image/BufferedImage;
at com.cage.zxing4p3.ZXING4P.decodeImage(ZXING4P.java:123)
at processing.test.lycee_loth.Lycee_Loth.mouseReleased(Lycee_Loth.java:441)
at processing.core.PApplet.mouseReleased(Unknown Source)
at processing.core.PApplet.handleMouseEvent(Unknown Source)
at processing.core.PApplet.dequeueEvents(Unknown Source)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.image.BufferedImage" on path: DexPathList[[zip file "/data/app/processing.test.lycee_loth-2/base.apk"],nativeLibraryDirectories=[/data/app/processing.test.lycee_loth-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 9 more
With qrcodeprocessing :
FATAL EXCEPTION: Thread-2
Process: processing.test.lycee_loth, PID: 22435
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/image/BufferedImage;
at qrcodeprocessing.Decoder.scanImage(Decoder.java:113)
at qrcodeprocessing.Decoder.run(Decoder.java:70)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.awt.image.BufferedImage" on path: DexPathList[[zip file "/data/app/processing.test.lycee_loth-1/base.apk"],nativeLibraryDirectories=[/data/app/processing.test.lycee_loth-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 2 more
In my application, when I touch the screen :
if (qr_code == true) { // When the QR code menu is on
//camera.savePhoto("qr_code_a_decoder.jpg");
//photos.add(loadImage("/storage/emulated/0/Pictures/savedFrames/qr_code_a_decoder.jpg"));
PImage code = createImage(camera.width, camera.height, RGB);
code.copy(camera, 0, 0, camera.width, camera.height, 0, 0, camera.width, camera.height);
code.updatePixels();
//messageDecode = zxing4p.decodeImage(true, loadImage("qr_test.jpg"));
//println(messageDecode);
decoder.decodeImage(code);
}
Is anybody has an idea ? :) Thanks.
Answers
those first two are the same problem:
i don't think the java.awt buffered images are available for android. which would mean you can't use zxing or qrcode. perhaps there are android equivalents?
there is a specific android version of zxing - https://github.com/zxing/zxing - which might help. i guess you are using the processing library version...
Ok, I understand, I was just asking myself if these libraries could work with android mode. I will try the new library that you notified me, I'll tell you if it solved my issue ;) Thank you :)
But now, there is one more question, how to install it ? I'm sorry, but the only one library that I installed is readBox and I putted it in processing-3.3\modes\java\libraries but with this one it isn't working. Is it because it is not a java library for processing ? I don't find anything about how to install android libraries ...
@Felix56===
you dont need any lib for doing that; just use the android API //developers.google.com/android/reference/com/google/android/gms/vision/barcode/BarcodeDetector
and make some imports
That belongs to the installation path. We shouldn't modify any of those folders unless we know what we're doing! [-X
Use your sketchbook folder path instead. Hit CTRL + COMMA in order to config it. :-B
Hi @akenaton, How can I use it with processing ? I tried to import them but they are not recognised by processing. I never created android applications except with MIT AppInventor 2. So I'm very interested about your solution. Thank you for your comment @GoToLoop.
@Felix56===
sorry; i have too much things to do and i' ll post ASAP;
yet= have you read the google docs for that??? - Have you add (meta-tags) GSM;vision asdependencies??? - Anyway i cannot see why it could not work with processing, and i am sure that it works because i have written app for that (with eclipse).
OK, I'll take more time this weekend to work on it and I will let you know about my progress. Thank you for your precious help. :)
Hello, I don't find anything about how to use these libraries with android mode for processing. I also find an other library for processing, but I think that I can't use it with the android mode. Here is the link (it is an old library) : thomasdiewald.com/blog/?p=855 I tried to integrate it in my application, but during the "building", I have this error :
I'm waiting for your next answer, thank you for all. :)
I fixed this problem, now I can run my application with the diewald's library. The problem was that I was using zxing library at the same time. But the diewald's library is based on zxing, so there were some issues using these two at the same time. But now, when I try to decode a qrcode with this new library, I have the following issue :
It seems to be the same type of issue than the others that I already posted
Thank you, still wainting for help ... :)
@Felix56=== java awt image cannot be used with android which has its own graphics package, hence the error: no workaround.
Ok, I understand. So we can conclude that we can't use the libraries that I found. But you talked about another solution which use BarcodeDetector with the Android API :
So do you know how I could integrate it in my Processing code ? I also tried to convert the image with this import :
import android.graphics;
(from here : https://developer.android.com/reference/android/graphics/package-summary.html) But I don't understand how it works and what it's doing ... Thank you.
Hey Felix56, I remember dealing with a similar issue a while back. Unfortunately, I do't remember how I solved it in the end but I do remember it took some fiddling about to resolve.
Hey @Abbie6 thank you for your comment but do you remember if you used librairies for this ? Or had you to change the file format of the file to decode ? Do you remember when you did it ? What was the result ? It's been a long time that I'm looking for a solution to fix this problem. I hope that it will finally works because I need to finish it as quick as possible... Still looking for other solutions ...