Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashlytics for Android generates conflicting provider #444

Closed
deckerst opened this issue Sep 4, 2018 · 13 comments
Closed

Crashlytics for Android generates conflicting provider #444

deckerst opened this issue Sep 4, 2018 · 13 comments
Assignees
Labels
investigating Currently investigating this issue

Comments

@deckerst
Copy link

deckerst commented Sep 4, 2018

Crashlytics aar manifest relies on ${applicationId} for its providers. One of them is misinterpreted and replaced by dollar_openBracket_applicationId_closeBracket in the final app manifest:

        <provider
            android:name="com.crashlytics.android.CrashlyticsInitProvider"
            android:exported="false"
            android:authorities="bpu.aimei.crashlyticsinitprovider"
            android:initOrder="100" />

        <provider
            android:name="com.crashlytics.android.CrashlyticsInitProvider"
            android:exported="false"
            android:authorities="dollar_openBracket_applicationId_closeBracket"
            android:initOrder="100" />

As this is a static string it is not unique to the app, so it conflicts with any other app that also uses Crashlytics. Installation of the second app will then fail with INSTALL_FAILED_CONFLICTING_PROVIDER. This is a blocker for us as we developed several Xamarin apps and we urgently need to replace Firebase Crash Reporting by Crashlytics in all of them.

@newky2k newky2k added the investigating Currently investigating this issue label Sep 4, 2018
@Redth
Copy link
Member

Redth commented Sep 4, 2018

After some investigation it looks like the original .aar file contains /aapt/AndroidManifest.xml which appears to be a 'sanitized' version of the manifest file for use with aapt, which removes unsupported characters (such as ${} found if using the ${applicationId} placeholder) (https://github.com/xamarin/Essentials/pull/416/files#diff-0402adc5e47d9aa94d7ccec496686a60R3).

This second manifest file is getting picked up by xamarin.android during the build process (this is evidenced by the fact that we see two <provider entries in the final merged manifest, one with the proper application id, and one with the escaped placeholder).

Given that Xamarin.Android rewrites these placeholders before sending to aapt anyway, I think it probably should be ignoring manifests found in the /aapt/ folder of .aar files.

In the meantime we can probably patch Xamarin.Build.Download to also drop these entries when embedding the .aar in the .dll at build time.

@jonathanpeppers
Copy link
Member

This issue was moved to dotnet/android#2141

@Redth
Copy link
Member

Redth commented Sep 6, 2018

@deckerst can you please try the prerelease version of Xamarin.Build.Downoad (0.4.12-preview) which should ignore the duplicate (and incorrect) provider.

https://www.nuget.org/packages/Xamarin.Build.Download/0.4.12-preview

@deckerst
Copy link
Author

deckerst commented Sep 7, 2018

Thanks for the quick release, but I've tried it and the final apk manifest still has the incorrect provider:

        <provider
            android:name="com.crashlytics.android.CrashlyticsInitProvider"
            android:exported="false"
            android:authorities="dollar_openBracket_applicationId_closeBracket"
            android:initOrder="100" />

I cleaned everything (bin/obj/packages) and I double-checked the XBD package version was right. Was the fix working for you?

@Redth
Copy link
Member

Redth commented Sep 7, 2018

Forgot one step. You'll need to wipe out your local nuget cache as well as any local packages folders. You need to get a fresh install of the nuget packages which haven't yet been altered by Xamarin.build.download since it skips the step this fix is in if it's already been done previously.

@deckerst
Copy link
Author

deckerst commented Sep 7, 2018

I wiped the following and retried, to no avail (mac environment):

  • ~/.local/share/NuGet
  • ~/.nuget/packages
  • solution packages
  • project bin & obj

@Redth
Copy link
Member

Redth commented Sep 7, 2018

@deckerst apologies, there was still a bug in that release. 0.4.12-preview3 is now available and is working well locally for me: https://www.nuget.org/packages/Xamarin.Build.Download/0.4.12-preview3

Please:

  1. Update the Nuget Package to 0.4.12-preview3
  2. Restart the IDE
  3. Delete all cached locations of NuGet Packages
  4. Delete bin/obj
  5. Rebuild

@jldubz
Copy link

jldubz commented Sep 25, 2018

I finally got this to work after some pain clearing and restoring the nuget cache.

The steps I followed were:

  1. Updated the Nuget Package to 0.4.12-preview3
  2. Restarted the IDE
  3. Cleared the Nuget cache through Tools -> Option -> Nuget Package Manager -> General -> Clear All Nuget Cache(s)
  4. Loaded the Solution
  5. Restored Nuget Packages for the Solution
  6. Rebuilt and ran

It was at this point that I started getting errors at the line of code that initializes Fabric with Crashlytics Fabric.Fabric.With(this, new Crashlytics.Crashlytics());
Saying that the package Fabric.io was missing. I had to install and then uninstall the Fabric, Xamarin.Android.Crashlytics.Answers, and Xamarin.Android.Crashlytics.Beta packages to get through a few of these errors, and now everything is up and running. I'm not sure why I have to manually load those packages into the Nuget Cache, but that has been the thorn in my side for the last day.

@SagarPanwala
Copy link

still able to reproduce on VS Mac
Followed all above steps.
still getting the same error. Xamarin.Build.Download version is 0.5.0-rc1

@Dooks123
Copy link

Dooks123 commented Jun 3, 2019

I'm still getting the issue where it generates the duplicate providers where one is correct but a second one with dollar_openBracket_applicationId_closeBracket is also added.

  • Xamarin.Android.Fabric v1.4.3
  • Xamarin.Android.Crashlytics.Core v2.6.3
  • Xamarin.Android.Crashlytics.Beta v1.2.9
  • Xamarin.Android.Crashlytics.Answers v1.4.2
  • Xamarin.Android.Crashlytics v2.9.4.1
  • Xamarin.Build.Download v0.4.11

@hemantbeast
Copy link

@Redth Still happening this issue with the XBD 0.9.0 version. Can't able to install the app.

  • Xamarin.Android.Fabric v1.4.3.4
  • Xamarin.Android.Crashlytics.Core v2.6.3.4
  • Xamarin.Android.Crashlytics.Beta v1.2.9.4
  • Xamarin.Android.Crashlytics.Answers v1.4.2.4
  • Xamarin.Android.Crashlytics v2.9.4.4
  • Xamarin.Build.Download v0.9.0

@Dooks123
Copy link

Dooks123 commented Mar 4, 2020

@Redth Still happening this issue with the XBD 0.9.0 version. Can't able to install the app.

  • Xamarin.Android.Fabric v1.4.3.4
  • Xamarin.Android.Crashlytics.Core v2.6.3.4
  • Xamarin.Android.Crashlytics.Beta v1.2.9.4
  • Xamarin.Android.Crashlytics.Answers v1.4.2.4
  • Xamarin.Android.Crashlytics v2.9.4.4
  • Xamarin.Build.Download v0.9.0

I have made a discovery to get around this issue here:
Crashlytics for Android generates conflicting provider #590

@jonathanpeppers
Copy link
Member

@hemantbeast @Dooks123 this issue should be resolved by:

dotnet/android#2144

Can you file a new issue here: https://github.com/xamarin/xamarin-android/issues

Include a diagnostic MSBuild log or a sample project we can try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigating Currently investigating this issue
Projects
None yet
Development

No branches or pull requests

9 participants