System.TypeLoadException when using PlayerNotificationManager.IMediaDescriptionAdapter
segfaults-behind-you opened this issue Β· comments
π Bug Report
Application crashes when class that implements interface:
PlayerNotificationManager.IMediaDescriptionAdapter
is being instantiated.
Exception that is thrown:
Could not load type 'Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.IMediaDescriptionAdapter' from assembly 'ExoPlayer.UI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Other interfaces provided by PlayerNotificationManager present the same behaviour.
Possibly some other nested types may also cause the app to crash when implemented or referenced, might be worth checking.
Expected behavior
It would be cool, if it wouldn't crash. :~D
Reproduction steps
Try to run the attached project on a physical android device or on an emulator.
- Build and Run the application.
- During deployment to the device exception should be thrown.
Configuration
Android 9
Version:
2.11.4
Platform:
- π± iOS
- π€ Android
- π WPF
- π UWP
- π MacOS
- πΊ tvOS
- π Xamarin.Forms
I can definitively confirm that I'm getting the same Exception thrown on the latest version of Exoplayer with Android 10 as well.. Would be nice indeed if it didn't crash but oh well.
Still seems to be an issue on 2.11.6 combined with the latest version of XamarinMediaManager (0.9.9)
@martijn00 Could you have a look at this?
It works fine here: https://github.com/Baseflow/XamarinMediaManager/blob/70afbdb223d6377f8648cb9f3f9c873946a506df/MediaManager/Platforms/Android/Media/MediaDescriptionAdapter.cs#L13
You need to enable C#8 and target Android 10 with AndroidX
Could this be re-opened? I'm still getting the same exception with the sample below (Which is based off of the sample with the original issue's sample, just updated to 2.11.6 and c#8 enabled)
@jessewtf
Same here.
These are the settings, that I've set. I guess this should do the trick, but doesn't. Also AndroidX seems to be turned on - screenshot which shows that MainActivity inherits from AndroidX.[...].
This is a clean Forms project, only exoplayer was added.
@martijn00 Would you be able to provide some pointers, please? Am I missing something?
If you want me to look into this you can make a PR or send me an email for commercial support.
Hi @martijn00 . I'm a bit confused about your approach.
Maybe this and other interfaces that can't be instantiated are part of commercial support. In such case, you should state it clearly in README so that everyone can make conscious decision if want to use your software or not.
Apart form that if you can't provide working instructions how to run your software, why would I pay you for commercial support? This doesn't add up for me.
Either way everyone would want to know if this is paid feature or you have no idea how to fix it because it simply works for you.
I've looked some more into this. It seems that (at least on my mac) there is some issue during type loading.
In RuntimeTypeHandle.cs line 342 (This file comes from mono), there is:
var t = internal_from_name (typeName, ref stackMark, null, throwOnError, ignoreCase, false);
if (throwOnError && t == null)
throw new TypeLoadException ("Error loading '" + typeName + "'");
So in my case on macOS, some interfaces that are nested in PlayerNotificationManager have typeName that follows the following convention:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager/NESTED_INTERFACE, ExoPlayer.UI
for example:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager/ICustomActionReceiverInvoker, ExoPlayer.UI
but for PlayerNotificationManager.IMediaDescriptionAdapter it looks like this:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.IMediaDescriptionAdapter, ExoPlayer.UI
and this part causes the exception to be thrown.
After changing it to:
Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager/IMediaDescriptionAdapter, ExoPlayer.UI
during debug, application runs as expected and notification is shown.
I guess this can be changed in ExoPlayer.UI/Transforms/Metadata.xml
but I am not really sure how to do it right now.
I could try to create a PR with a fix, but I would have to read some more about java bindings.
Would you be able to look into this? @martijn00
Also this seems to be the same thing happening, but to the other interface:
#108
EDIT: 14.07.2020
After further investigation it seems that this is exactly the issue we are facing:
xamarin/java.interop#661
I've created Exoplayer.UI nuget package locally with <_EnableInterfaceMembers>true</_EnableInterfaceMembers>
removed - then the package doesn't contain methods that have default implementations in java - for our case, this is enough for now.
I've tried to create a binding on macOS with VS updated from the current preview channel, but the fix does not seem to be there yet. Because the registration still has dot "." instead of slash "/".
[Register ("getCurrentSubText", "(Lcom/google/android/exoplayer2/Player;)Ljava/lang/CharSequence;", "GetGetCurrentSubText_Lcom_google_android_exoplayer2_Player_Handler:Com.Google.Android.Exoplayer2.UI.PlayerNotificationManager.IMediaDescriptionAdapter, ExoPlayer.UI")]
unsafe ICharSequence GetCurrentSubTextFormatted (IPlayer player);
I guess we'll have to wait for the binding generator to work properly.