-
Notifications
You must be signed in to change notification settings - Fork 42
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
MediaSessionCompat exists in multiple assemblies #71
Comments
Why do you have both Android.Support and AnroidX? if you reference both - of course you will have the same class twice. 1st solution - use FQClassNames (Fully Qualified), do not add both namespaces in 2nd solution - If some libraries that you use reference Android.Support - contact library authors/vendors and ask THEM to update their libs to AndroidX dependencies. Under the hood is Jettifier tool used by google too. it should work on dependencies that are not migrated to AndroidX, but there are several exceptional cases (some libraries are known issue for Android java/kotlin developers). BTW. Can you post here your source file (usings), please? |
Hi, thanks for getting back to me. As you say, it's not that we are taking a direct dependency on both Android.Support and AndroidX, but that some of our dependencies require AndroidX and some only have versions available with dependencies on Android.Support. I will get in touch with the vendors and request updates, but I'm hoping there is a way to have this project compile in the meantime. I tried using fully qualified class names, but unfortunately this does not resolve things, I believe in this case that the class names exist in the same namespaces in both the Android.Support libraries and the AndroidX libraries. For example, I've checked in ILSpy and the MediaMetadataCompat type, for example, is in the Android.Support.V4.Media namespace in both assemblies. It was my understanding that including the Xamarin.AndroidX.Migration package should allow us to proceed in this scenario, in the same manner as the Jettifier tool should. Sure, I'll add an some example code below, thanks:
In this file, we have issues with the MediaDescriptionCompat, MediaMetadataCompat, and MediaSessionCompat. |
You're welcome. BTW no reason to thank me. Helping is the reason why we are here for.
Not even google can solve all problems with jettifier. There are libraries which cause problems in java/kotlin world with AndroidX. And we add substantial amount of complexity on top of java/kotlin world. Is your code publicly open so I/we could check? And: forget ExoPlayer and Player packages for now. They are quite complex to bind and I simply cannot gat some time to finish them. (I dislike to do |
Related (possible duplicate): |
Related (possible duplicate): Why not trying tips described here? This is an issue we know about, but there may be a workaround:
Whole discussion: |
Cool, that all makes sense. The code isn't open source, but I could probably put together a small reproduction app if you would like one? I went through the workarounds in the issueyou linked. Removing and re-adding the assembly (first suggestion) resulted in different error messages: 'MyQueueNavigator.GetMediaDescription(IPlayer, int)': return type must be 'MediaDescriptionCompat' to match overridden member 'TimelineQueueNavigator.GetMediaDescription(IPlayer, int)' The type 'MediaDescriptionCompat' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The type 'MediaSessionCompat' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. I suspect these might be due to the fact that I'm overriding a contract owned by a dependency that owns the references and points them at Support, but this is just a guess. The good news is that the other workaround, of defining an extern alias, has indeed solved the issue! This seems to work fine on Visual Studio on Windows, however on Visual Studio for Mac there are visual errors highlighed, although the actual compilation completes with no problems. In case anyone else runs into this issue the following is the target I added to the bottom of my Droid .csproj file:
making the code file above:
|
Sorry for delay, but I wanted to release new set of AndroidX (Corona) updates, before I get back to issues and fixing 'em.
Sure. you know the more samples we/I have - the better. We'll hit issues sooner, before they get to users (you). So,YES please. Where did you find ExoPlayer bindings? |
Hey, also apologies for the delay. It might be some time before I can put together a repro, but I will get to it. In the meantime, I'm using these ExoPlayer bindings :) |
@markmccaigue |
Closing this one, because it is stale. |
Xamarin Android Version: 10.1.3.7
Operating System & Version: Mac OS 10.14.6
Support Libraries Version: 28.0.0.1
Describe your Issue:
I have a project with transitive dependencies which reference the Xamarin.Android.Support.Media.Compat package, and some which reference the newer Xamarin.AndroidX.Media package.
I have installed the Xamarin.AndroidX.Migration package.
When I attempt to reference the type MediaSessionCompat, I recieve the following error message:
Error CS0433: The type 'MediaSessionCompat' exists in both 'Xamarin.Android.Support.Media.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Xamarin.AndroidX.Media, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' (CS0433)
I'm not sure if this scenario is supposed to be handled by the tooling, or if there is some other change I should have made to the project as part of the migration.
Many thanks for your help.
The text was updated successfully, but these errors were encountered: