Comments (10)
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 using
statements.
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?
from androidx.
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:
using Android.Support.V4.Media;
using Android.Support.V4.Media.Session;
using Com.Google.Android.Exoplayer2;
using Com.Google.Android.Exoplayer2.Ext.Mediasession;
namespace TheAppBuilder.Droid.BackgroundMedia
{
public class MyQueueNavigator : TimelineQueueNavigator
{
public MyQueueNavigator(MediaSessionCompat mediaSession) : base(mediaSession)
{
}
public override MediaDescriptionCompat GetMediaDescription(IPlayer player, int windowIndex)
{
var metadata = BackgroundAudioPlayerService.CurrentTrack;
var builder = new MediaDescriptionCompat.Builder()
.SetMediaId(metadata.GetString(MediaMetadataCompat.MetadataKeyMediaId))
.SetTitle(metadata.GetString(MediaMetadataCompat.MetadataKeyDisplayTitle))
.SetSubtitle(metadata.GetString(MediaMetadataCompat.MetadataKeyDisplaySubtitle))
.SetDescription(metadata.GetString(MediaMetadataCompat.MetadataKeyDisplayDescription));
var displayIconUri = metadata.GetString(MediaMetadataCompat.MetadataKeyDisplayIconUri);
if (displayIconUri != null)
{
builder.SetIconUri(UriUtility.FromString(displayIconUri));
}
return builder.Build();
}
}
}
In this file, we have issues with the MediaDescriptionCompat, MediaMetadataCompat, and MediaSessionCompat.
from androidx.
thanks for getting back to me.
You're welcome. BTW no reason to thank me. Helping is the reason why we are here for.
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.
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.
Xamarin.AndroidX.Migration package works in most cases, but there could be problems for sure.
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 <remove-node>
during bindings).
from androidx.
Related (possible duplicate):
from androidx.
Related (possible duplicate):
Why not trying tips described here?
This is an issue we know about, but there may be a workaround:
Whole discussion:
from androidx.
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:
<Target Name="AddCustomAliases" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
<ItemGroup>
<ReferencePath Condition="'%(FileName)' == 'Xamarin.Android.Support.Media.Compat' AND '%(ReferencePath.NuGetPackageId)' == 'Xamarin.Android.Support.Media.Compat'">
<Aliases>AndroidSupportMedia</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
making the code file above:
extern alias AndroidSupportMedia;
using AndroidSupportMedia::Android.Support.V4.Media;
using AndroidSupportMedia::Android.Support.V4.Media.Session;
using Com.Google.Android.Exoplayer2;
using Com.Google.Android.Exoplayer2.Ext.Mediasession;
namespace TheAppBuilder.Droid.BackgroundMedia
{
public class MyQueueNavigator : TimelineQueueNavigator
{
public MyQueueNavigator(MediaSessionCompat mediaSession) : base(mediaSession)
{
}
public override MediaDescriptionCompat GetMediaDescription(IPlayer player, int windowIndex)
{
var metadata = BackgroundAudioPlayerService.CurrentTrack;
var displayIconUri = metadata.GetString(MediaMetadataCompat.MetadataKeyDisplayIconUri);
var builder = new MediaDescriptionCompat.Builder()
.SetMediaId(metadata.GetString(MediaMetadataCompat.MetadataKeyMediaId))
.SetTitle(metadata.GetString(MediaMetadataCompat.MetadataKeyDisplayTitle))
.SetSubtitle(metadata.GetString(MediaMetadataCompat.MetadataKeyDisplaySubtitle))
.SetDescription(metadata.GetString(MediaMetadataCompat.MetadataKeyDisplayDescription));
if (displayIconUri != null)
{
builder.SetIconUri(UriUtility.FromString(displayIconUri));
}
return builder.Build();
}
}
}
from androidx.
Sorry for delay, but I wanted to release new set of AndroidX (Corona) updates, before I get back to issues and fixing 'em.
but I could probably put together a small reproduction app if you would like one?
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?
from androidx.
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 :)
https://github.com/Baseflow/ExoPlayerXamarin
from androidx.
@markmccaigue
Thanks. I found it, but confirmation is great.
That ExoPlayer is not AndroidX version.
from androidx.
Closing this one, because it is stale.
Open new issue if the problem still persists.
from androidx.
Related Issues (20)
- CustomTabsSession.RequestPostMessageChannel() throws exception HOT 1
- Xamarin.Androidx.Lifecycle.Common error while using Xamarin.Firebase.Messaging HOT 3
- Type-forwarding for binding libraries HOT 3
- Deprecate Xamarin.AndroidX.Legacy.Support.V4 HOT 2
- Bind "androidx.credentials" HOT 16
- [Bug] Lottie package throwing error while creating the release build in Android after switching to target framework 13 HOT 26
- Bind "androidx.health:health-services-client" HOT 34
- Releases - Where are they? HOT 1
- [Bug] `androidx.credentials` null Exception HOT 6
- com.android.tools.r8.ResourceException: com.android.tools.r8.internal.vc: I/O exception while reading HOT 3
- AndroidX.Credentials ICredentialManagerCallback wrong parameter types. HOT 2
- Can't get past `javac: error: package androidx.fragment.app does not exist` HOT 4
- CameraSelector.Builder().AddCameraFilter effectively unusable (cannot select specific camera lens) HOT 2
- Xamarin.AndroidX.Biometric not building starting at version 1.1.0.17 (.NET MAUI) HOT 3
- Issue with CustomTabsActivityManager and multiple activities HOT 3
- Bind "androidx/emoji2/emoji2-picker" HOT 2
- Announcement: Xamarin.Android and .NET 6/7 no longer supported
- "Specified cast is not valid" when using SetOnItemSelectedListener of NavigationBarView HOT 6
- `Xamarin.Jetbrains.Annotations` namespace clash with `JetBrains.Annotations` causes CS0433 build failure HOT 1
- Can't install Xamarin.AndroidX.AppCompat and RecyclerView latest versions into Xamarin project HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidx.