Error on Scan UI loading: "com.google.mlkit.common.MlKitException: Failed to scan code."
I have a problem with my device. When the Scan UI is loading (on GmsBarcodeScanning) i'm getting exception addOnFailureListener. "com.google.mlkit.common.MlKitException: Failed to scan code." In other devices i cannot get the same bug... but more than one for sure. Some one have any workaround to fix it? Tnk
Platform: Android Project: com.google.mlkit.samples.codescanner
There is a workaround.
Always send an install request. If the barcode scanner module is already installed it will not be installed again.
Send an urgent module install request
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val moduleInstall = ModuleInstall.getClient(this)
val moduleInstallRequest = ModuleInstallRequest.newBuilder()
.addApi(GmsBarcodeScanning.getClient(this))
.build()
moduleInstall
.installModules(moduleInstallRequest)
.addOnSuccessListener {
if (it.areModulesAlreadyInstalled()) {
// Modules are already installed when the request is sent.
}
}
.addOnFailureListener {
// Handle failure…
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With