Hi,
I have been testing the Android Barcode Scanner and here is what I experienced:
- There is no indication that the barcode scanner won’t work if the correct ML Kit library isn’t installed. It just returns an error.
- Apparently Play Store downloads it with no indication to the user. In my case, it didn’t work the entire first day, but the next day it was suddenly able to scan. There was no notification that anything was downloaded or installed.
- At first, it couldn’t scan anything and seemed slow. A few minutes later it started working as intended.
I think it would be an awful experience for my clients to have to go through this, not knowing when their app will be able to properly scan. The only thing I can do is put up a message box asking them to wait…
So I’m hoping there might be some way for me to include the ML Kit in my APK.
For Code Scanner documentation here https://developers.google.com/ml-kit/vision/barcode-scanning/code-scanner it says:
This API uses an unbundled library that must be downloaded before use. See this guide for more information.
But the guide they link to suggests that “Barcode Scanning” can be bundled at build time, while “Google Code Scanner” is unbundled.
Is there any way to set the Xojo Android Barcode Scanner to use the Barcode Scanning library and bundle it? Or is there some recommended guidance for handling the strange behavior by the Google Code Scanner while it awaits the library download? Any way to use this in an offline environment?
Thanks!
-Mike
From what I understand, Android actually “updates” on a schedule, usually when the user has their device plugged in and charging without use.
This is their way of remaining “cheap” on use of space. I was coding in Kotlin for a brief stint (and, for the record, I hate it with a passion) and Gradle would update ONLY as necessary, which means libraries are constantly in and out of use and are being swapped around periodically during updates.
I don’t know if there’s even a way to verify that the necessary library is installed.
I think this is why I’ve seen devices with instructions mandating that users turn them on to set up and then leave them for one whole day to “charge” and “allow for system updates to happen?”
I read the guide and it looks like Google Play has to get updated when the app triggers the need - I’m trying to figure out how to bundle it. So your devices needs to sit until Google Play gets updated, which by default should occur either in the background or when the device is plugged in and not moving for a few hours.
It looks like you will lose access to any newly improved functionality that is created after the point of time in which a library / model becomes bundled with your app, not sure if you want to lock a feature like that.
How to download models
When using the unbundled model option, you can specify how you want models to be downloaded to the device:
- You can enable install-time model downloads by adding a declaration to your app’s
AndroidManifest.xml
file. For example, the code snippet below shows how to configure your app to automatically download the Barcode Scanning model after your app is installed from the Play Store:
<application ...>
...
<meta-data
android:name="com.google.mlkit.vision.DEPENDENCIES"
android:value="barcode" >
<!-- To use multiple models: android:value="barcode,model2,model3" -->
</application>
- You can request explicit download through Google Play Services ModuleInstallClient API.
- If you don’t enable install-time model downloads or request explicit download, the model will be downloaded the first time you run the feature. Until the download is completed, inference requests will fail.
How to update models
To update your models when using the bundled model or the dynamically downloaded models option:
- Update your app’s gradle file to use the latest ML Kit feature client library.
dependencies {
implementation 'com.google.mlkit:barcode-scanning: 17.3.0' // The latest version number of the API
}
- Rebuild your app.
The above text came from ML Kit model installation paths on Android | Google for Developers and it looks like if you edit the app’s manifest file, you can trigger the download to occur, and then trigger updates.
I hope this helps!
1 Like