B4A Library MobileVisionBarcodeScanner

A shortcut wrap for this Github project. You will also need some other jars that you should download from here:
https://www.dropbox.com/s/tlabkzlwynggzx2/OtherJars.zip?dl=0

Leaving you with the Java code too - do with it as you like.

Extract resource.zip, DemoRes.zip, and LibRes.zip and copy the folders and their contents to be on the same folder level as that of the /Files and /Objects folders of the B4A project.

Take note of the B4A manifest file.

Option to return the "first barcode" found or to return the result of multiple barcodes found - use the check boxes (From xml and the refresh button are especially important if you want to get the text boxes and frames to be visible - sure you will figure it out)

3 different events raised in the B4A project

Tested on KitKat and Lollipop and working on both.

Library:
MobileVisionBarcodeScanner
Author:
Github: Nosakhare Belvi, Wrapped by: Johan Schoeman
Version: 1.02
  • MVBarcodeScanner
    Events:
    • all_barcodes_found (all_barcodes_found As String)
    • barcode_retrieved (displayvalue As String)
    • closest_to_click (closest_to_click As String)
    Methods:
    • Initialize (paramString As String)
    • IsInitialized As Boolean
    • Start_MVBarcodeScanner
    Permissions:
    • android.permission.CAMERA



1.jpg
 

Attachments

  • resource.zip
    423 bytes · Views: 522
  • LibRes.zip
    2 KB · Views: 532
  • b4aMVBarcodeScanner.zip
    8.8 KB · Views: 559
  • MobileVisionBarcodeScannerLibFiles.zip
    48.5 KB · Views: 528
  • DemoRes.zip
    57.5 KB · Views: 532
  • TheJavaCode.zip
    33.3 KB · Views: 451
Last edited:

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
I can't compile:

B4X:
B4A version: 6.00
Parsing code.    (0.00s)
Compiling code.    (0.06s)
Compiling layouts code.    (0.07s)
Organizing libraries.    (0.00s)
Generating R file.    Error
..\demores\values\styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'.
..\demores\values\styles.xml:8: error: Error: No resource found that matches the given name: attr 'colorAccent'.
..\demores\values\styles.xml:6: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
..\demores\values\styles.xml:7: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
..\resource\values\themes.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'.
..\resource\values\themes.xml:6: error: Error: No resource found that matches the given name: attr 'colorAccent'.
..\resource\values\themes.xml:4: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
..\resource\values\themes.xml:5: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.

My folder structure is showed in the image.

Any idea to can solve this problem?
 

Attachments

  • Captura.JPG
    Captura.JPG
    28 KB · Views: 387
Last edited:

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I can't compile:

B4X:
B4A version: 6.00
Parsing code.    (0.00s)
Compiling code.    (0.06s)
Compiling layouts code.    (0.07s)
Organizing libraries.    (0.00s)
Generating R file.    Error
..\demores\values\styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'.
..\demores\values\styles.xml:8: error: Error: No resource found that matches the given name: attr 'colorAccent'.
..\demores\values\styles.xml:6: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
..\demores\values\styles.xml:7: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
..\resource\values\themes.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'.
..\resource\values\themes.xml:6: error: Error: No resource found that matches the given name: attr 'colorAccent'.
..\resource\values\themes.xml:4: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
..\resource\values\themes.xml:5: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.

My folder structure is showed in the image.

Any idea to can solve this problem?
Do you use appcompat and have a theme ?

You can add this to your manifest and try again
B4X:
SetApplicationAttribute(android:theme, "@style/MyAppTheme")

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="colorAccent">#AAAA00</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>
</resources>
)
 

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
This post solved my problem: https://www.b4x.com/android/forum/t...ces_lib-res-does-not-exist.67126/#post-424879

I can compile yet!!!

I've got it in this way:

1) Download Google Play Services v29 from https://www.b4x.com/android/forum/t...ces_lib-res-does-not-exist.67126/#post-424879 and unzip in C:\xxxx\extras\google\google_play_services

2)
B4X:
#AdditionalRes: ..\resource
#AdditionalRes: ..\LibRes
#AdditionalRes: ..\DemoRes


'#AdditionalRes: C:\Android\android-sdk\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\Android\android-sdk\extras\android\m2repository\com\android, android.support.design
#AdditionalRes: C:\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

#Extends: android.support.v7.app.AppCompatActivity

3)
upload_2016-10-25_10-7-9.png


4)
upload_2016-10-25_10-9-38.png
 

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
But now, I got an error (Application stoped) when I push "Star MVBarcodeScanner"

B4X:
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/vision/barcode/BarcodeDetector$Builder;
    at com.google.android.gms.samples.vision.barcodereader.BarcodeCapture.createCameraSource(BarcodeCapture.java:178)
    at com.google.android.gms.samples.vision.barcodereader.BarcodeCapture.onCreateView(BarcodeCapture.java:102)
    at android.support.v4.app.Fragment.performCreateView(Fragment.java:2087)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1273)
    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1375)
    at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2420)
    at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:120)
    at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:378)
    at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:33)
    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:77)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:766)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
    at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
    at xyz.belvi.mobilevisionbarcodesample.MainActivity.onCreate(MainActivity.java:59)
    at android.app.Activity.performCreate(Activity.java:6876)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
    at android.app.ActivityThread.access$1100(ActivityThread.java:221)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7225)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.vision.barcode.BarcodeDetector$Builder" on path: DexPathList[[zip file "/data/app/JHS.MVBarcodeScanner-2/base.apk"],nativeLibraryDirectories=[/data/app/JHS.MVBarcodeScanner-2/lib/arm, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 35 more
    Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.vision.barcode.BarcodeDetector$Builder
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
        ... 36 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Resuelto un poco más abajo en: https://www.b4x.com/android/forum/threads/mobilevisionbarcodescanner.72232/#post-459994
 
Last edited:

Gabino A. de la Gala

Well-Known Member
Licensed User
Longtime User
Using v29 of the support-lib is NOT the right solution.
The right solution is to use the newest maven repos and andditional compatible libraries with these repos.

Thanks for your help!!!

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

#AdditionalRes: ..\resource
#AdditionalRes: ..\LibRes
#AdditionalRes: ..\DemoRes


'#AdditionalRes: C:\Android\android-sdk\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\Android\android-sdk\extras\android\m2repository\com\android, android.support.design
'#AdditionalRes: C:\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms 

#AdditionalJar: com.google.android.gms:play-services-vision

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

#Extends: android.support.v7.app.AppCompatActivity

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