JimmyPun610 / BarcodeScanner.Mobile

Barcode Scanner using GoogleVision API for Xamarin Form, Maui
MIT License
333 stars 100 forks source link

Xamarin.Android Release failed to build the project because of Unable to get provider com.google.mlkit.common.internal.MlKitInitProvider #122

Closed valerii-sovytskyi closed 2 years ago

valerii-sovytskyi commented 2 years ago

Xamarin android that targets Android 12 (API 31)

The issue: For my case I was not able to RUN the application on release mode, and by researching I found that the problem was next:

Unable to get provider com.google.mlkit.common.internal.MlKitInitProvider

To fix this issue I needed to update the AndroidManifest.xml

Just add this code

~~<provider android:name="com.google.mlkit.common.internal.MlKitInitProvider" android:authorities="${your app id}.mlkitinitprovider" tools:node="remove" /> <meta-data android:name="com.google.mlkit.vision.DEPENDENCIES" android:value="barcode" />~~ And inside Manifest

xmlns:tools="http://schemas.android.com/tools"

I'm suggesting to update the Wiki section so developers will add it to the AndroidManifest

image

The fix found here https://developers.google.com/ml-kit/vision/barcode-scanning/android

UPD: The fix for my case was to set Code shrinker to be empty, not R8

JimmyPun610 commented 2 years ago

Interesting. Didn't get this error.... Anyway, I have added into wiki. Thanks a lot

valerii-sovytskyi commented 2 years ago

Sorry, but I didn't test it well, this fix is not working, the crash was fixed, but the Scanner is not working I guess because I removed MLKit at all, I will update you on my investigation

valerii-sovytskyi commented 2 years ago

@JimmyPun610 The problem was here Android Options -> Code shrinker -> not to be r8 in my case it's an empty selector.

Please, remove what I suggested.

image