Android Question Suddenly google code scanner (based on ML kit) not working

The ML kit based Google Scanner was working but no longer works. I haven't changed any thing in code. When the 'button' is tapped, brief black screen appears and app goes back to main page. No discernible error is shown. How to rectify it? This is the log: Is it got something to do with 'Transport backend 'cct' is not registered' ? Also what are all those strange com.hunantv.imgo.activity, com.tencent.qqlive, com.qiyi.video, com.hunantv.imgo.activity.inter, com.tencent.qqlivei18n, com.iqiyi.i18n, tv.danmaku.bili] ?
 
Fresh download and running of code too doesn't work. The complete log is below:

 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
com.hunantv.imgo.activity, com.tencent.qqlive, com.qiyi.video, com.hunantv.imgo.activity.inter, com.tencent.qqlivei18n, com.iqiyi.i18n, tv.danmaku.bili
You are seeing the system logs. It includes the output of all apps.

Change the scan method code to:
B4X:
Public Sub Scan (Formats As List) As ResumableSub
    Dim builder As JavaObject
    builder.InitializeNewInstance("com/google/mlkit/vision/codescanner/GmsBarcodeScannerOptions.Builder".Replace("/", "."), Null)
    Dim f(Formats.Size - 1) As Int
    For i = 1 To Formats.Size - 1
        f(i - 1) = Formats.Get(i)
    Next
    builder.RunMethod("setBarcodeFormats", Array(Formats.Get(0), f))
'    builder.RunMethod("enableAutoZoom", Null)
    Dim options As JavaObject = builder.RunMethod("build", Null)
    Dim scanning As JavaObject
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim scanner As JavaObject = scanning.InitializeStatic("com/google/mlkit/vision/codescanner/GmsBarcodeScanning".Replace("/", ".")).RunMethod("getClient", Array(ctxt, options))
    Dim o As JavaObject = scanner.RunMethod("startScan", Null)
    Do While o.RunMethod("isComplete", Null).As(Boolean) = False
        Sleep(50)
    Loop
    Dim res As ScannerResult
    res.Initialize
    If o.RunMethod("isSuccessful", Null) Then
        res.Success = True
        res.Barcode = o.RunMethod("getResult", Null)
        res.Value = res.Barcode.RunMethod("getRawValue", Null)
    Else
        Log("error: " & o.RunMethod("getException", Null))
    End If
    Return res
End Sub

Post the filtered logs.
 
Upvote 0
Thanks for looking into the issue. The filtered Log after changing code:

 
Upvote 0
Upvote 0
If you have another device to test then try it.

Deleting Google Play Services cache might help. Also try to restart the device.
Interestingly, it works in older phone! First time it shows error as it apparently downloads 'Barcode UI module' and then it starts working.
Log:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…