Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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=, 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.

  1. Build and Run the application.
  2. During deployment to the device exception should be thrown.


Android 9 Version: 2.11.4 Platform:

  • 📱 iOS
  • 🤖 Android
  • 🏁 WPF
  • 🌎 UWP
  • 🍎 MacOS
  • 📺 tvOS
  • 🐒 Xamarin.Forms

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

senior-sigsegvcommented, Jul 10, 2020

@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.

Screenshot 2020-07-02 at 23 07 34 Screenshot 2020-07-02 at 23 08 21 Screenshot 2020-07-02 at 23 09 18 Screenshot 2020-07-02 at 23 10 50 Screenshot 2020-07-02 at 23 23 11

@martijn00 Would you be able to provide some pointers, please? Am I missing something?

senior-sigsegvcommented, Jul 14, 2020

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:

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found