Android Question [SOLVED] QR-Code - Barcode Reader Getting Error java.lang.reflect.InvocationTargetException

George_G

Member
Licensed User
Hello,

I have seen this post
https://www.b4x.com/android/forum/t...invocationtargetexception.147664/#post-935953

and I have already added

this to manifest
B4X:
AddApplicationText(<meta-data
    android:name="com.google.android.gms.vision.DEPENDENCIES"
    android:value="barcode,,face" />
)

and this in Main
B4X:
#AdditionalJar: com.google.android.gms:play-services-vision

My Manifest:


B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136

'in addmanifesttext the following text, removed on 3/2/2022
'<uses-library android:name="org.apache.http.legacy" android:required="false" />
AddManifestText(
<uses-sdk android:minSdkVersion="20" android:targetSdkVersion="33"/>
<supports-screens android:largeScreens="true"

    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")


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>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)

AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera.flash" android:required="false" />)
AddPermission("android.permission.CAMERA")
AddPermission("android.permission.FLASHLIGHT")
AddPermission("android.hardware.camera")

AddApplicationText(<meta-data
    android:name="com.google.android.gms.vision.DEPENDENCIES"
    android:value="barcode,,face" />
)

My Error:

B4X:
Error occurred on line: 340 (CustomerCode)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4a.ProfitPDA.customercode._createdetector(customercode.java:651)
    at b4a.ProfitPDA.customercode$ResumableSub_Activity_Create.resume(customercode.java:557)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.zzf(com.google.android.gms:play-services-basement@@18.1.0:6)
    at com.google.android.gms.dynamite.DynamiteModule.zza(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.dynamite.zze.zzb(com.google.android.gms:play-services-basement@@18.1.0:1)
    at com.google.android.gms.dynamite.zzk.selectModule(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.load(com.google.android.gms:play-services-basement@@18.1.0:5)
    at com.google.android.gms.internal.vision.zzt.zzd(com.google.android.gms:play-services-vision-common@@19.1.3:24)
    at com.google.android.gms.internal.vision.zzm.<init>(com.google.android.gms:play-services-vision@@20.1.3:3)
    at com.google.android.gms.vision.barcode.BarcodeDetector$Builder.build(com.google.android.gms:play-services-vision@@20.1.3:7)
    ... 24 more
Logger connected to: R3CTB0ESQWY
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
discountPassword=1312
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
0
** Activity (main) Pause, UserClosed = false **
** Activity (mainmenu) Create (first time) **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (tools) Create (first time) **
** Activity (tools) Resume **
** Activity (tools) Pause, UserClosed = false **
** Activity (customercode) Create (first time) **
** Activity (customercode) Resume **
Yes Camera
Error occurred on line: 340 (CustomerCode)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4a.ProfitPDA.customercode._createdetector(customercode.java:651)
    at b4a.ProfitPDA.customercode$ResumableSub_Activity_Create.resume(customercode.java:557)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.zzf(com.google.android.gms:play-services-basement@@18.1.0:6)
    at com.google.android.gms.dynamite.DynamiteModule.zza(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.dynamite.zze.zzb(com.google.android.gms:play-services-basement@@18.1.0:1)
    at com.google.android.gms.dynamite.zzk.selectModule(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.load(com.google.android.gms:play-services-basement@@18.1.0:5)
    at com.google.android.gms.internal.vision.zzt.zzd(com.google.android.gms:play-services-vision-common@@19.1.3:24)
    at com.google.android.gms.internal.vision.zzm.<init>(com.google.android.gms:play-services-vision@@20.1.3:3)
    at com.google.android.gms.vision.barcode.BarcodeDetector$Builder.build(com.google.android.gms:play-services-vision@@20.1.3:7)
    ... 24 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
discountPassword=1312
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
0
** Activity (main) Pause, UserClosed = false **
** Activity (mainmenu) Create (first time) **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (tools) Create (first time) **
** Activity (tools) Resume **
** Activity (tools) Pause, UserClosed = false **
** Activity (customercode) Create (first time) **
** Activity (customercode) Resume **
Yes Camera
Error occurred on line: 340 (CustomerCode)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4a.ProfitPDA.customercode._createdetector(customercode.java:651)
    at b4a.ProfitPDA.customercode$ResumableSub_Activity_Create.resume(customercode.java:557)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.zzf(com.google.android.gms:play-services-basement@@18.1.0:6)
    at com.google.android.gms.dynamite.DynamiteModule.zza(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.dynamite.zze.zzb(com.google.android.gms:play-services-basement@@18.1.0:1)
    at com.google.android.gms.dynamite.zzk.selectModule(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.load(com.google.android.gms:play-services-basement@@18.1.0:5)
    at com.google.android.gms.internal.vision.zzt.zzd(com.google.android.gms:play-services-vision-common@@19.1.3:24)
    at com.google.android.gms.internal.vision.zzm.<init>(com.google.android.gms:play-services-vision@@20.1.3:3)
    at com.google.android.gms.vision.barcode.BarcodeDetector$Builder.build(com.google.android.gms:play-services-vision@@20.1.3:7)
    ... 24 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
discountPassword=1312
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
0
** Activity (main) Pause, UserClosed = false **
** Activity (mainmenu) Create (first time) **
** Activity (mainmenu) Resume **
** Activity (mainmenu) Pause, UserClosed = false **
** Activity (tools) Create (first time) **
** Activity (tools) Resume **
** Activity (tools) Pause, UserClosed = false **
** Activity (customercode) Create (first time) **
** Activity (customercode) Resume **
Yes Camera
Error occurred on line: 340 (CustomerCode)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4a.ProfitPDA.customercode._createdetector(customercode.java:651)
    at b4a.ProfitPDA.customercode$ResumableSub_Activity_Create.resume(customercode.java:557)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
    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.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Caused by: com.google.android.gms.common.GooglePlayServicesMissingManifestValueException: A required meta-data tag in your app's AndroidManifest.xml does not exist.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.common.GoogleApiAvailabilityLight.isGooglePlayServicesAvailable(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.zzf(com.google.android.gms:play-services-basement@@18.1.0:6)
    at com.google.android.gms.dynamite.DynamiteModule.zza(com.google.android.gms:play-services-basement@@18.1.0:8)
    at com.google.android.gms.dynamite.zze.zzb(com.google.android.gms:play-services-basement@@18.1.0:1)
    at com.google.android.gms.dynamite.zzk.selectModule(com.google.android.gms:play-services-basement@@18.1.0:2)
    at com.google.android.gms.dynamite.DynamiteModule.load(com.google.android.gms:play-services-basement@@18.1.0:5)
    at com.google.android.gms.internal.vision.zzt.zzd(com.google.android.gms:play-services-vision-common@@19.1.3:24)
    at com.google.android.gms.internal.vision.zzm.<init>(com.google.android.gms:play-services-vision@@20.1.3:3)
    at com.google.android.gms.vision.barcode.BarcodeDetector$Builder.build(com.google.android.gms:play-services-vision@@20.1.3:7)
    ... 24 more
 
Last edited:

George_G

Member
Licensed User
Solved.

I added this to manifest:


B4X:
AddApplicationText(
    <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
you FORGOT to add
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
to your manifest?
 
Upvote 0

George_G

Member
Licensed User
you FORGOT to add
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
to your manifest?
Hello Mr DonManfred,

it solved with this addition to manifest:
B4X:
AddApplicationText(
    <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
)
 
Last edited:
Upvote 0
Top