Maui: [BUG] MediaElement Android video player throws exception
Is there an existing issue for this?
- I have searched the existing issues
Did you read the “Reporting a bug” section on Contributing file?
- I have read the “Reporting a bug” section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
in .net 9 maui, upgraded to the latest nuget packages as of today (27 Jan. 2025), MediaLElement version 6.0.0 When load the video player on Android (API 22), the following error threw:
Could not determine Java type corresponding to AndroidX.Media3.ExoPlayer.IExoPlayerInvoker, Xamarin.AndroidX.Media3.ExoPlayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. (Parameter ‘targetType’)
Expected Behavior
Video player worked fine prior to the nuget upgrades, video will play in the mediaElement. The new community toolkit nuget package broke the video player.
Steps To Reproduce
in. net 9 with all the latest nuget packages,
- Create a Xaml PAGE with the mediaElement instance.
- Set the mediaElement source video to a local video.
- When the page load, the exception throws
Link to public reproduction project repository
na
Environment
- .NET MAUI CommunityToolkit: latest nuget package as 27 Jan 2025
- .Net 9
- .on Android API 31
Anything else?
The problem only happens on Android verison.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 36 (14 by maintainers)
I re-opened this issue for tracking purpose as @dhindrik and @dainius-r have also experiencing the same issue with the same repo. Even thoguh I don’t have to produce my own sample repo now.
I looked at the sample. I figured out an easy way to make the video work.
AndroidManifest.xml
MainPage.xaml
Replace with above and it should work. It is not pretty but it will compile and run on android. No it will not work for every supported OS. But you can take it from here. If you have any more questions please open a discussion and ask there. I tested the revised version with android and API 34. Please move this to a discussion as this is not a bug.