Android Question Object should first be initialized

jackdev65

Member
Licensed User
Hi All

This is not a B4X Pages project it is a large application I have been maintaining for some 6+ years now. We are looking to add QR Code scanning support so I have tried both BillScanner and this solution: https://www.b4x.com/android/forum/threads/qrcodereaderview-new-release.82265/#post-520876

Using either I am encountering similar issues despite following the setup and sample projects to a T.

Error:

1726140440706.png


Which occurs at the first line of this method:

B4X:
Sub StartQRScanning
    qrcrv.Visible = True
    qrcrv.startScan
    rpe.CheckAndRequest(rpe.PERMISSION_CAMERA)
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = True Then
        Log("camera perms given")
        'bs1.Initialize("bs1")
        'bs1.Enabled = True
        'bs1.Visible = True
        'bs1.startScanning
        
        Else
            ToastMessageShow("Camera service must be accepted to scan QR Codes", True)
    End If
    
    
End Sub

I have tried simply adding this on Activity_Create
B4X:
qrcrv.Initialize("")
I have also tried creating the object in Globals and also Process_Globals
B4X:
Private qrcrv As QRCodeReaderView

Here is my manifest:
Manifest:
'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.basic4ppc.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="33"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />   

)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:supportsRtl, "true")
'End of default text.

SetActivityAttribute(Main,  android:windowSoftInputMode, "stateHidden|adjustPan")


SetApplicationAttribute(android:theme, "@style/MyAppTheme")

SetApplicationAttribute(android:usesCleartextTraffic, "true")

CreateResource(values, themes.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">#4f7c8b</item>
        <item name="colorPrimaryDark">#588A9B</item>
        <item name="colorAccent">#4f7c8b</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
    </style>
    
    
</resources>

)


CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)

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>
)
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.ACCESS_COARSE_LOCATION")
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.ACCESS_FINE_LOCATION")
AddPermission("android.permission.WAKE_LOCK")
AddPermission("android.permission.DEVICE_POWER")
'AddPermission("android.permission.ACCESS_COARSE_UPDATES")
AddPermission("android.permission.READ_PHONE_STATE")
AddPermission("android.permission.VIBRATE")
AddPermission("android.permission.CAMERA")
AddPermission("android.permission.FLASHLIGHT")
AddPermission("android.hardware.camera")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

And my list of libraries

1726139950336.png



I feel it could be something obvious I am missing, any help would be greatly appreciated!

Thanks
 

Spavlyuk

Active Member
Licensed User
Have you tried Google Code Scanner?
 
Upvote 0
Top