Closed mv4wd closed 1 month ago
Xamarin Classic -> Xamarin.Forms is out of support.
Besides why using olde nugets:
https://www.nuget.org/packages/Xamarin.Google.MLKit.Common/118.10.0.3
https://www.nuget.org/packages/Xamarin.Forms/5.0.0.2662
https://www.nuget.org/packages/Xamarin.Essentials/1.8.1
??
Even if you would provide repro sample I am afraid I/we would not be able to test it and investigate.
Unfortunately this is a legacy app that has a lot of dependencies and would require quite an effort to upgrade. Anyway, I've been able to pass the GetClient exception by manually adding in the Android manifest the following lines that I've extracted from a 'modern' test app.
<provider android:name="com.google.mlkit.common.internal.MlKitInitProvider" android:authorities="com.TesySoftware.TLogClient.mlkitinitprovider" android:exported="false" android:initOrder="99" />
<service android:name="com.google.mlkit.common.internal.MlKitComponentDiscoveryService" android:directBootAware="true" android:exported="false" tools:targetApi="n">
<meta-data android:name="com.google.firebase.components:com.google.mlkit.common.internal.CommonComponentRegistrar" android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data android:name="com.google.firebase.components:com.google.mlkit.vision.common.internal.VisionCommonRegistrar" android:value="com.google.firebase.components.ComponentRegistrar" />
<meta-data android:name="com.google.firebase.components:com.google.mlkit.vision.text.internal.TextRegistrar" android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
Adding this lines also a avoids the need to call MlKit.Initialize
Unfortunately this is a legacy app that has a lot of dependencies and would require quite an effort to upgrade.
It will be even more effort not to upgrade.
Anyway, I've been able to pass the GetClient exception by manually adding in the Android manifest the following lines that I've extracted from a 'modern' test app.
Does that solve the issue?
If yes. I guess this is solution/workaround for now, but please do migrate to MAUI and newer netX.0
targets (8, 9).
<provider android:name="com.google.mlkit.common.internal.MlKitInitProvider" android:authorities="com.TesySoftware.TLogClient.mlkitinitprovider" android:exported="false" android:initOrder="99" /> <service android:name="com.google.mlkit.common.internal.MlKitComponentDiscoveryService" android:directBootAware="true" android:exported="false" tools:targetApi="n"> <meta-data android:name="com.google.firebase.components:com.google.mlkit.common.internal.CommonComponentRegistrar" android:value="com.google.firebase.components.ComponentRegistrar" /> <meta-data android:name="com.google.firebase.components:com.google.mlkit.vision.common.internal.VisionCommonRegistrar" android:value="com.google.firebase.components.ComponentRegistrar" /> <meta-data android:name="com.google.firebase.components:com.google.mlkit.vision.text.internal.TextRegistrar" android:value="com.google.firebase.components.ComponentRegistrar" /> </service>
Adding this lines also a avoids the need to call MlKit.Initialize
Thanks for letting us know. Appreciated.
I've also added these two sections in the manifest, and I'm able to analyze and extract Text items from the image succesfully. This is just a spare-time proof of concept, If a 'sponsor' will be interested the migration to MAUI is on the to-do list. Unfotunately I'm also dealing with old hardware used in the factories, with outdated Android, and any change is always a possible source of issues.
<service android:name="com.google.android.datatransport.runtime.backends.TransportBackendDiscovery" android:exported="false">
<meta-data android:name="backend:com.google.android.datatransport.cct.CctBackendFactory" android:value="cct" />
</service>
<uses-library android:name="com.google.mlkit.text-recognition" android:required="false" />
@mv4wd Thanks for the feedback.
I've also added these two sections in the manifest,
Thanks for the feedback.
and I'm able to analyze and extract Text items from the image succesfully.
Great. Glad to hear that.
This is just a spare-time proof of concept, If a 'sponsor' will be interested the migration to MAUI is on the to-do list.
Do you have minimal repro sample?
Regarding MAUI: I need to see state of MLKit on iOS.
Unfotunately I'm also dealing with old hardware used in the factories, with outdated Android, and any change is always a possible source of issues.
I have similar issues with my app[s] (not living in US or western Europe).
Describe your Issue
This is an old Xamarin application where I would like to add MLKit text decoding (bundled model, as to not download it from PlayService, usually not available in the installation). I've added the Xamarin packages and can succesfully compile, but when I run the app and try to obtain the TextRecognizer, I get the following exception
Exception throw:
Attempt to invoke virtual method 'com.google.mlkit.vision.text.TextRecognizer com.google.mlkit.vision.text.internal.zzm.zza(com.google.mlkit.vision.text.TextRecognizerOptionsInterface)' on a null object reference
One Issue that I see on the console, is that when I call MlKit.Initialize, I get these messages:
By reading the google docs, it seems like that, to use the bundled Text model, a key element is the gradle configuration
But I see no way to mimic this in VS. Is a Mono working sample for bundled com.google.mlkit.vision.text.TextRecognizer available?
Thanks. Marco
Operating System & Version
Android 8.1.0
Google Play Services Version
N/A
Relevant information
Build settings (tools)
Include any relevant Exception Stack traces, build logs, adb logs: