I have tried to use this library that works on B4X by @Erel.
With the example included in the original post, without touching anything in the code, just assigning the code that I want to read.
This PDF417 code, the application can read it without problems
This code, crash
With the original example, just switching to the code format I want to read, this is the error that stops execution and crashes. I tried it on the Motorola and on a Samsung S23 and the problem is the same
In another post, @TILogistic and @aeric have suggested me to use ZXing, I did it and it works perfect, but it is not compatible with B4I. I have contacted @Johan Schoeman, he confirms that it is not compatible.
@Erel, can you please see why the app crashes when trying to read the second example of the PDF 417 code?
[B4X] [B4XPages] Barcode Reader
B4A + B4i barcode reader. Don't miss: - #PlistExtra in B4i. - Manifest code + #AdditionalJar in B4A Depends on BCToast: https://www.b4x.com/android/forum/threads/b4x-bctoast-cross-platform-custom-toast-message.111046/#content (BCToast will be an internal library in the near future) While the...
www.b4x.com
With the example included in the original post, without touching anything in the code, just assigning the code that I want to read.
PDF 417:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
toast.Initialize(Root)
StopCamera
B4XPages.SetTitle(Me, "Barcode Example")
#if B4A
CreateDetector (Array("PDF417"))
#Else if B4i
scanner.Initialize2("scanner", pnlPreview, Array(scanner.TYPE_93, scanner.TYPE_128, scanner.TYPE_QR))
Wait For Scanner_Ready (Success As Boolean)
If Success = False Then
btnStartStop.Enabled = False
toast.Show("Failed to initialize the scanner.")
End If
#end if
End Sub
This PDF417 code, the application can read it without problems
This code, crash
With the original example, just switching to the code format I want to read, this is the error that stops execution and crashes. I tried it on the Motorola and on a Samsung S23 and the problem is the same
Logger connected to: motorola motorola edge 30 pro
--------- beginning of main
** Activity (main) Pause event (activity is not paused). **
** Activity (main) Resume **
findCamera
null
2
facing: 0, 0
findCamera
0
2
facing: 0, 0
Preview Orientation: 90
b4xmainpage_camera1_preview (java line: 110)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4a.example.b4xmainpage._camera1_preview(b4xmainpage.java:110)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
at b4a.example.cameraexclass._camera_preview(cameraexclass.java:146)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.CameraW$2$1$1.onPreviewFrame(CameraW.java:147)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1193)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8118)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.google.android.gms.vision.barcode.BarcodeDetector.detect(com.google.android.gmslay-services-vision@@20.1.3:27)
... 20 more
Copying updated assets files (5)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
findCamera
null
2
facing: 0, 0
findCamera
0
2
facing: 0, 0
Preview Orientation: 90
Error occurred on line: 140 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
at b4a.example.b4xmainpage._camera1_preview(b4xmainpage.java:398)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
at b4a.example.cameraexclass._camera_preview(cameraexclass.java:354)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.CameraW$2$1$1.onPreviewFrame(CameraW.java:147)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1193)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loopOnce(Looper.java:238)
at android.os.Looper.loop(Looper.java:357)
at android.app.ActivityThread.main(ActivityThread.java:8118)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:957)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
at com.google.android.gms.vision.barcode.BarcodeDetector.detect(com.google.android.gmslay-services-vision@@20.1.3:27)
... 28 more
In another post, @TILogistic and @aeric have suggested me to use ZXing, I did it and it works perfect, but it is not compatible with B4I. I have contacted @Johan Schoeman, he confirms that it is not compatible.
@Erel, can you please see why the app crashes when trying to read the second example of the PDF 417 code?