Forum Xamarin.Android

FirebaseInitProvider class not found in dex file

MamunPriyaMamunPriya Member ✭✭
edited December 2019 in Xamarin.Android

Hi,
The android app in "DEBUG" is working fine with all features including but we are facing some issue while releasing the app in play store.

The issue facing
While initialization the app is crashing showing this error
Issue: java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.mvt.mstntapp-1/base.apk", zip file "/data/app/com.mvt.mstntapp-1/split_config.arm64_v8a.apk", zip file "/data/app/com.mvt.mstntapp-1/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.mvt.mstntapp-1/lib/arm64, /data/app/com.mvt.mstntapp-1/base.apk!/lib/arm64-v8a, /data/app/com.mvt.mstntapp-1/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/com.mvt.mstntapp-1/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /system/vendor/lib64, /product/lib64]]

Which says the com.google.firebase.provider.FirebaseInitProvider is not present in any Dex file.
What is the build configuration for Android release
We tried several configuration combinations like -

The Pink highlighted configurations combination is tried differently.
The same thing is happening when we enable multidex in debug mode too.

The tools used..
Visual Studio version 16.3.6(Professional)
Xamarin version 16.3.0.227
Xamarin Android SDK 10.0.3.0
Xamarin IOS SDK 13.4.0.2

Posts

  • RobSchoenakerRobSchoenaker NLMember ✭✭
    edited December 2019

    Disable R8 and use ProGuard. Solved my problem:

  • batmacibatmaci DEMember ✭✭✭✭✭

    @RobSchoenaker said:
    Disable R8 and use ProGuard. Solved my problem:

    thats not a solution. thats a workaround. R8 is becomin more standard for Android by google and we need to use this option. if it is not production ready, somebody from Xamarin team needs to clarify it.

  • RobSchoenakerRobSchoenaker NLMember ✭✭

    Your question was: "What is the build configuration for Android release", so I would opt this for a working 'solution'. That is, for now. I agree that R8 should be usable, but this seems not to be the case just yet.

  • Ross_BRoss_B USMember ✭✭

    We are facing this same issue. Is using ProGuard still the recommended approach? I have tried enabling multidex (at recommendation of some Stack Overflow posts), but it did not work.

    Sorry to bump an old thread, but searching through the forums this seems like the best place.

  • Ross_BRoss_B USMember ✭✭

    I was able to resolve from the advice in https://forums.xamarin.com/discussion/comment/275568/#Comment_275568.

    In summary:

    • Created Proguard configuration for Android project to ensure Firebase classes are not removed from final archive:

      -dontwarn com.google.android.gms.**
      -keep class com.google.android.gms.** { *; }
      -keep class com.google.firebase.** { *; }
      
    • Was able to keep using R8 shrinker, as it is backwards compatible and still uses Proguard configuration. My Android build config:

    Hope it helps someone else.

Sign In or Register to comment.