Hi,
After enabling:
#R8Optimizer: True
I encountered this error when calling Scan in the GoogleCodeScanner class, version 1.00:
java.lang.ClassNotFoundException: com.google.mlkit.vision$codescanner$GmsBarcodeScannerOptions$Builder
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(SourceFile:89)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(SourceFile:1)
at com.oficinadirecta.googlecodescanner$ResumableSub_Scan.resume(SourceFile:577)
The failure occurs before the scanner opens, on this line:
builder.InitializeNewInstance("com/google/mlkit/vision/codescanner/GmsBarcodeScannerOptions.Builder".Replace("/", "."), Null)
This appears to be related to R8 removing or renaming classes accessed through JavaObject. The class names are constructed using .Replace, which prevents automatic detection of these references by the B4A compiler.
Proposed fix
Add the following to the Manifest Editor, keeping any existing ProGuard rules:
AddProguardText(
-keep class com.google.mlkit.vision.codescanner.** { *; }
-keep class com.google.mlkit.vision.barcode.common.** { *; }
-keep class com.google.android.gms.tasks.** { *; }
)
These rules cover the scanner and its options, including Builder, the barcode result and the Google Tasks methods called through JavaObject: isComplete, isSuccessful and getResult.
The complete scanning flow still needs to be verified in a clean Release build with R8 enabled.