System.TypeLoadException when using PlayerNotificationManager.IMediaDescriptionAdapter
See original GitHub issue🐛 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to debug System.TypeLoadException errors in .NET?
I had two projects compiling to DLLs with the same name. Check the "Assembly name" in the project's properties' "Application" section.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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?
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:
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: https://github.com/xamarin/java.interop/issues/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 “/”.
I guess we’ll have to wait for the binding generator to work properly.