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 #2141

Closed
jonathanpeppers opened this issue Sep 4, 2018 · 8 comments
Closed

Crashlytics for Android generates conflicting provider #2141

jonathanpeppers opened this issue Sep 4, 2018 · 8 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended. enhancement Proposed change to current functionality.

Comments

@jonathanpeppers
Copy link
Member

From @deckerst on September 4, 2018 6:54

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.

Copied from original issue: xamarin/XamarinComponents#444

@jonathanpeppers
Copy link
Member Author

From @Redth on September 4, 2018 20:43

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 jonathanpeppers added bug Component does not function as intended. enhancement Proposed change to current functionality. Area: App+Library Build Issues when building Library projects or Application projects. and removed Under Investigation labels Sep 4, 2018
@jonathanpeppers
Copy link
Member Author

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Sep 5, 2018
Context: https://stackoverflow.com/questions/41592744/function-of-aapt-androidmanifest-xml-in-aar
Fixes: dotnet#2141

Apparently Android Studio is now shipping a duplicate, pre-formatted
`AndroidManifest.xml` file, inside of AAR files. Its purpose is to be
used with `aapt` invocations, since errors may be thrown related to
`{` or `}` characters.

Since this file may exist in AAR files used by Xamarin.Android, we
should ignore `aapt/AndroidManifest.xml` files the same way we ignore
them inside `manifest` or `bin` directories.

Changes:
- Added a `IgnoredManifestDirectories` list, since we are getting to a
  point where `!= && != && !=` would be a lot of noise.
- Switched the LINQ expression to simple `foreach` loop, which should
  also give a slight performance benefit.
jonathanpeppers referenced this issue Sep 5, 2018
But the app project fails to build with:

obj\Debug\android\src\mono\io\fabric\sdk\android\services\events\EventsStorageListenerImplementor.java(8,40):  error: package io.fabric.sdk.android.services.events does not exist
		io.fabric.sdk.android.services.events.EventsStorageListener
 [C:\Users\jopepper\Desktop\Git\xamarin-android\bin\TestDebug\temp\ExtraAaptManifest\UnnamedProject.csproj]
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Sep 5, 2018
Context: https://stackoverflow.com/questions/41592744/function-of-aapt-androidmanifest-xml-in-aar
Fixes: dotnet#2141

Apparently Android Studio is now shipping a duplicate, pre-formatted
`AndroidManifest.xml` file, inside of AAR files. Its purpose is to be
used with `aapt` invocations, since errors may be thrown related to
`{` or `}` characters.

Since this file may exist in AAR files used by Xamarin.Android, we
should ignore `aapt/AndroidManifest.xml` files the same way we ignore
them inside `manifest` or `bin` directories.

Changes:
- Added a `IgnoredManifestDirectories` list, since we are getting to a
  point where `!= && != && !=` would be a lot of noise.
- Switched the LINQ expression to simple `foreach` loop, which should
  also give a slight performance benefit.
dellis1972 pushed a commit that referenced this issue Sep 7, 2018
* [Xamarin.Android.Build.Tasks] ignore aapt/AndroidManifest.xml

Context: https://stackoverflow.com/questions/41592744/function-of-aapt-androidmanifest-xml-in-aar
Fixes: #2141

Apparently Android Studio is now shipping a duplicate, pre-formatted
`AndroidManifest.xml` file, inside of AAR files. Its purpose is to be
used with `aapt` invocations, since errors may be thrown related to
`{` or `}` characters.

Since this file may exist in AAR files used by Xamarin.Android, we
should ignore `aapt/AndroidManifest.xml` files the same way we ignore
them inside `manifest` or `bin` directories.

Changes:
- Added a `IgnoredManifestDirectories` list, since we are getting to a
  point where `!= && != && !=` would be a lot of noise.
- Switched the LINQ expression to simple `foreach` loop, which should
  also give a slight performance benefit.

* Fix test on MacOS
@nidhinvnm
Copy link

I have updated to the latest version of Visual Studio. Still getting the same error while installing multiple apps with crashlytics

PFB visual studio details

Visual Studio Community 2017 for Mac
Version 7.7.1 (build 15)
Installation UUID: 37dcc1b3-4054-4a5e-b0d5-be25ef184812
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

Package version: 516000221

Mono Framework MDK
Runtime:
Mono 5.16.0.221 (2018-06/b63e5378e38) (64-bit)
Package version: 516000221

NuGet
Version: 4.7.0.5148

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.2
2.1.1
2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
2.1.302
2.1.301
2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
Version: 1.6.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Apple Developer Tools
Xcode 9.4 (14160)
Build 9F1027a

Xamarin.Mac
Version: 5.2.1.12 (Visual Studio Community)
Hash: 65ec520f
Branch:
Build date: 2018-12-05 12:06:09-0500

Xamarin.iOS
Version: 12.2.1.12 (Visual Studio Community)
Hash: 65ec520f
Branch: d15-9
Build date: 2018-12-05 12:06:09-0500

Xamarin.Android
Version: 9.1.4.2 (Visual Studio Community)
Android SDK: /Users/a962906/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 27.0.1
SDK Build Tools Version: 25.0.3

Java SDK: /Users/a962906/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.9
openjdk version "1.8.0-9"
OpenJDK Runtime Environment (build 1.8.0-9-microsoft-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android Device Manager
Version: 7.7.1.0
Hash: 06ceaea1

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 707010015
Git revision: a7ca4daaf7add8fe05ed137fdd51bd9eb77758a7
Build date: 2018-12-05 20:15:35+00
Build branch: release-7.7
Xamarin extensions: 40f5fc1b44727b10b1e7bb1ada3aae33516569ce

Operating System
Mac OS X 10.13.6
Darwin 17.7.0 Darwin Kernel Version 17.7.0
Thu Jun 21 22:53:14 PDT 2018
root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

@jonathanpeppers
Copy link
Member Author

@nidhinvnm this fix didn't make it into Xamarin.Android 9.1.x, due to poor timing, sorry.

You can get it in the Visual Studio 2019 previews today, I think the version of Xamarin.Android should be 9.1.100.x or higher.

@nidhinvnm
Copy link

Thanks @jonathanpeppers . It is working perfectly after installing Xamarin.Android 9.1.101.6 with Visual studio 2019 preview.
Thanks for your help :)

@sl-maelledelay
Copy link

Hi, if I understand the status of this bug correctly, I can't release a xamarin android application now with crashlytics installed?
The Xamarin.Android 9.1.101.6 is still in preview so not supposed to be used for app in production.
So do we have currently a solution? Or do I have to release my application without crashlytics?

Thanks for your help

@jonathanpeppers
Copy link
Member Author

@sl-maelledelay you might also try updating to the latest Xamarin.Build.Download, they put a workaround in there for this issue.

Searching Google, it currently says VS 2019's release date is April 2. There may be a preview that has a "go-live" license before that date--but I don't know for sure.

@sl-maelledelay
Copy link

@jonathanpeppers Thanks for your answer. The last version of Xamarin.Build.Download is a preview one. The lastest not in preview is 0.4.11. Is the workaround in this stable one?
Do you have more informations about the workaround?

@ghost ghost locked as resolved and limited conversation to collaborators Jun 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. bug Component does not function as intended. enhancement Proposed change to current functionality.
Projects
None yet
Development

No branches or pull requests

4 participants