Android Question Problem with zBarcodeScanner

David Elkington

Active Member
Licensed User
Longtime User
I was wondering if anyone could help. I have been using a barcode scanner in my app for ages, but now all of a sudden, I get an error when trying to initiate a scan. I have the error below, does anyone have any idea what is missing?

When I step though the code line by line, it seems to work

zb1.Visible = True
zb1.startScanner(backCamId)
b1.Visible=True



** Activity (mainmenu) Pause, UserClosed = false **
** Activity (qrallocation) Create, isFirst = true **
frontCamId = 1
backCamId = 0
** Activity (qrallocation) Resume **
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:255)
at android.content.res.Resources.getValue(Resources.java:1353)
at android.content.res.HwResources.getColor(HwResources.java:280)
at android.content.res.Resources.getColor(Resources.java:961)
at main.java.me.dm7.barcodescanner.core.ViewFinderView.<init>(ViewFinderView.java:39)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.createViewFinderView(BarcodeScannerView.java:57)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupLayout(BarcodeScannerView.java:40)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupCameraPreview(BarcodeScannerView.java:70)
at main.java.me.dm7.barcodescanner.core.CameraHandlerThread$1$1.run(CameraHandlerThread.java:31)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
 

Johan Schoeman

Expert
Licensed User
Longtime User
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Oh, my res/layout folder seems to be blank somehow, and the res/values folder is not present
See post #1 of where I have posted the library. Get the resource files into place and then let me know if it is working or not working. Remember to set the files to READ ONLY before you compile the B4A project.
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
Brilliant, Many thanks, that now works. I copied all the files to a new folder at some point and I guess the read only flag was removed... You will be getting a donation for sure....
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Brilliant, Many thanks, that now works. I copied all the files to a new folder at some point and I guess the read only flag was removed... You will be getting a donation for sure....
I guess you had the same issue with the other ZXING (Icefairy) project. It also contains resource files in sub folders of /Objects/res/blabla folders.
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
Now found the solution thanks to Johan. I was missing the res/layouts files due to read only flags being removed during a copy of the project folder... Many thanks, app now working again.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You should give Johan a few like for the effort he did to help you!

Which, if you had read the library release post carefully, where not needed at all.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Now found the solution thanks to Johan. I was missing the res/layouts files due to read only flags being removed during a copy of the project folder... Many thanks, app now working again.

Thanks David! Donation much appreciated!
 
Upvote 0

David Elkington

Active Member
Licensed User
Longtime User
Best is to upload a small project which shoes the issue.... No need for us to fish here....

But as I said, this has been working for ages, and I have released at least 40 versions of the app without any issues. I am not sure why the read only flag got removed, but it did, which was quite a hard spot in an app that is now 25mb...
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
But as I said, this has been working for ages, and I have released at least 40 versions of the app without any issues. I am not sure why the read only flag got removed, but it did, which was quite a hard spot in an app that is now 25mb...
At least we got it sorted out. That is all that is important!
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
But as I said, this has been working for ages, and I have released at least 40 versions of the app without any issues. I am not sure why the read only flag got removed, but it did, which was quite a hard spot in an app that is now 25mb...
You can create a folder on the same folder level as that of the /Objects and /Files folder of the B4A project. Call it LibRes. Then copy the layout and value folders with their contents to be sub folders (and files) of this newly created folder. Then in the B4A project you use

#AdditionalRes: ...\LibRes to reference the resources. You can then remove the folders and files in the /Objects/res/layout and Objects/res/ values folders.

When doing it this way you don't have to worry about setting the READ ONLY property of the files in the folders. Browse the forum to see how to use #AdditionalRes or see some examples of other projects that have been posted in e forum. It makes life a bit easier to do it this way.
 
Upvote 0

Mihai Rainer Jr.

Member
Licensed User
Hi, I am trying to use ZBar (1.03) with B4A (8.50), target 26, min target 19. The application is showing the viewport and laser line, but the viewport is black on Android 8.1
Checked permission, added runtime permission PERMISSION_CAMERA. Using SDK platform 28. Can you, please, advise? Thank you
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Hi, I am trying to use ZBar (1.03) with B4A (8.50), target 26, min target 19. The application is showing the viewport and laser line, but the viewport is black on Android 8.1
Checked permission, added runtime permission PERMISSION_CAMERA. Using SDK platform 28. Can you, please, advise? Thank you
Do you have the following:
1. merge_camera_preview_view_finder.xml in the /Objects/res/layout folder of your B4A project
2. colors.xml and strings.xml in the /Objects/res/values folder of your B4A project?

If you downloaded and unzipped the project then depending on what you have used to unzip the project might have disabled the "read only" properties of these files and when compiling with B4A they get deleted because they are no longer "read only".

The alternative is to extract and copy the attached folder LibRes and its contents to be on the same folder level as that of the /Files and /Objects folders of you B4A project and then reference the additional resources from within your B4A project:

B4X:
#Region  Project Attributes
    #ApplicationLabel: ZbarBarcodeScanner
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False

#End Region

#AdditionalRes: ..\LibRes              'ADD THE ADDITIONAL RESOURCES HERE

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
 

Attachments

  • LibRes.zip
    5.4 KB · Views: 275
Upvote 0

Mihai Rainer Jr.

Member
Licensed User
Well, it looks that was a matter of SDK configuration, as long as I have installed it again in a different directory and I found that the application is running now on my test devices, with Android 6.0 and 8.1
Thank you very much for your support, this forum is simply great :)
 
Upvote 0

figorra

Member
Licensed User
Longtime User
I have this error on ZbarBarcodeScanner......

The another answer don't work for me.....

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (escaneo) Create, isFirst = true **
frontCamId = 1
backCamId = 0
** Activity (escaneo) Resume **
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
at android.content.res.Resources.getColor(Resources.java:964)
at android.content.res.Resources.getColor(Resources.java:940)
at main.java.me.dm7.barcodescanner.core.ViewFinderView.<init>(ViewFinderView.java:39)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.createViewFinderView(BarcodeScannerView.java:57)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupLayout(BarcodeScannerView.java:40)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupCameraPreview(BarcodeScannerView.java:70)
at main.java.me.dm7.barcodescanner.core.CameraHandlerThread$1$1.run(CameraHandlerThread.java:31)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
I have this error on ZbarBarcodeScanner......

The another answer don't work for me.....

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (escaneo) Create, isFirst = true **
frontCamId = 1
backCamId = 0
** Activity (escaneo) Resume **
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:216)
at android.content.res.Resources.getColor(Resources.java:964)
at android.content.res.Resources.getColor(Resources.java:940)
at main.java.me.dm7.barcodescanner.core.ViewFinderView.<init>(ViewFinderView.java:39)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.createViewFinderView(BarcodeScannerView.java:57)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupLayout(BarcodeScannerView.java:40)
at main.java.me.dm7.barcodescanner.core.BarcodeScannerView.setupCameraPreview(BarcodeScannerView.java:70)
at main.java.me.dm7.barcodescanner.core.CameraHandlerThread$1$1.run(CameraHandlerThread.java:31)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Sure you have all the files in the Objects/res/layout folder and in the Objects/res/values folder and the files are all set to READ ONLY?
 
Upvote 0
Top