Android Question barecode app crash

Ennesima77

Member
Licensed User
Longtime User
Hi everybody,
after many years I came back yo use B4A, but I'm still a biginner and I need your help

I follow the post https://www.b4x.com/android/forum/threads/b4x-b4xpages-barcode-reader.120417/#content, but I get an error when I run new activity:

I add the manifest:
Manifest:
AddApplicationText(
 
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.
AddManifestText(<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />
    
)
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
  <meta-data
    android:name="com.google.android.gms.vision.DEPENDENCIES"
    android:value="barcode,,face" />
 )
 
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />

)
I hope in the correct way, but is tyhe first time I add more than one "addictional manifest text".

when code arrived here:

B4X:
builder.InitializeNewInstance("com/google/android/gms/vision/barcode/BarcodeDetector.Builder".Replace("/", "."), Array(ctxt))

I getting this error:
View attachment 115026

and application crash.
the same error occurent in the example, but example continue to works and barcode reader works.

what's wrong?

TY
 
Last edited:

Ennesima77

Member
Licensed User
Longtime User
I copy all code from Erel Example and add it into a new activity and I don't use delegated Class "B4XMainPage", just because I alredy have a MainPage and delagated Class and I dont' know how to use more than one delegated class.:eek::eek::eek:.
call me stupid, but as I said i'm a biginner.....
 
Upvote 0

Ennesima77

Member
Licensed User
Longtime User
B4XPages is explained here: [B4X] B4XPages - Cross platform and simple framework for managing multiple pages

You should have a single activity.
Create a new project and select B4XPages as its type.

TY Erel for your answer, and sorry for the late in my reply, I take a look on your link and I understud (more or less) the B4XMainPage usage, but I have the same problem to start the barcode reading.
I supposed the problems is the Manifest, just because the exception is:

B4X:
(Exception) java.lang.Exception:  java.lang.ClassNotFoundException: com.google.android.gms.vision$barcode$BarcodeDetector$Builder

I never add more then one Add-on on manifest, maybe I made some mistake in that.
 
Upvote 0

Ennesima77

Member
Licensed User
Longtime User
I found the problem:
as I supposed was my ignorance in "manifest" compilation.

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

'da riattivare
AddManifestText(<uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="18" />
    
)
AddApplicationText(
 <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
 </provider>
 
 )
 
 AddApplicationText(<meta-data
    android:name="com.google.android.gms.vision.DEPENDENCIES"
    android:value="barcode,,face" />
 )
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />

)
I need to ADD in a separted section.
and now barcode scanner is well integrated in my solutions!!!!!!!

????????
Happy!
 
Upvote 0
Top