mlkit
mlkit copied to clipboard
[Bug report] BarcodeScanning getClient - MlKitContext has not been initialized
Describe the bug
A clear and concise description of what the bug is.
We started seeing this rarely on some devices at the moment.
It is weird that getting MlKitContext has not been initialized
even though we are not manually initializing a context (neither disabled content-provider as well)
If applicable, please include code snippet
and sample input(image, video, text, etc)
java.lang.IllegalStateException: MlKitContext has not been initialized
at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.1.0:0)
at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.5.0:13)
at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@16.2.1:3)
Expected behavior A clear and concise description of what you expected to happen.
SDK Info:
- SDK Name & Version
com.google.mlkit:barcode-scanning:17.0.0
Smartphone:
- Device Armor 11 5G
We see this too, though rarely, on Poco F5 devices running Android 13 with com.google.mlkit:barcode-scanning:17.2.0
I had the same problem on OPPO , Android 13.
Caused by:
5
java.lang.IllegalStateException:MlKitContext has not been initialized
6
com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.1.0:2)
7
com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.7.0:1)
I am using these libraries:
implementation 'com.google.mlkit:barcode-scanning:17.1.0'
implementation 'com.google.mlkit:text-recognition:16.0.0-beta6'
implementation 'com.google.mlkit:text-recognition-chinese:16.0.0-beta6'
I just code in application.java MlKitContext.initializeIfNeeded(this);