CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.28k stars 404 forks source link

[BUG] .NET MAUI 8.0 Android 14: AndroidX.LocalBroadcastManager.Content.LocalBroadcastManager not supported on Android 13 and above. #2293

Open giannistek1 opened 1 month ago

giannistek1 commented 1 month ago

Is there an existing issue for this?

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

For context, I use an Android 14 Samsung Galaxy A34 and a .NET 8.0 MAUI app.

And I use MediaElement version 4.0.1 because 4.1.1 kept crashing, I did not bother updating.

Sentry keeps giving me this message (ever since I started using MediaElement 1-2 months ago): AndroidX.LocalBroadcastManager.Content.LocalBroadcastManager not supported on Android 13 and above.

Because src/CommunityToolkit.Maui.MediaElement/Views/MediaManager.android.cs: line 10 says: using AndroidX.LocalBroadcastManager.Content;

Very annoying and makes no sense because, yes I am using a newer Android version, shouldn't the code be updated to support Android 13+?

How do I turn this off or prevent this from sending or will there be a fix?

I googled a bit and someone said that it should be Android.Support instead of AndroidX.

Full call stack: ?, in void Logger.Log(LogLevel, EventId, TState, Exception, Func<TState, Exception, string>)+LoggerLog(LogLevel, EventId, ILogger, Exception, Func<FormattedLogValues, Exception, string>, ref List, in FormattedLogValues) ?, in void Logger.Log(LogLevel, EventId, FormattedLogValues, Exception, Func<FormattedLogValues, Exception, string>) ?, in void LoggerExtensions.Log(ILogger, LogLevel, EventId, Exception, string, params object[]) x 2 ?, in void LoggerExtensions.LogError(ILogger, string, params object[]) ?, in void MediaManager.BroadcastUpdate(string action) ?, in async void MediaManager.OnPlayerStateChanged(bool playWhenReady, int playbackState) ?, in void AsyncMethodBuilderCore.Start<d19>(ref d19) ?, in void MediaManager.OnPlayerStateChanged(bool playWhenReady, int playbackState) ?, in void DynamicMethodNameCounter.14(IntPtr, IntPtr, bool, int) ?, in void JniNativeMethods.wrapper_native_indirect_void_intptr_intptr_intptrintptr(ref IntPtr, IntPtr, IntPtr, IntPtr, IntPtr) ?, in void InstanceMethods.CallVoidMethod(JniObjectReference, JniMethodInfo, JniArgumentValue) ?, in void JNIEnv.CallVoidMethod(IntPtr, IntPtr, JValue) ?, in void IExoPlayerInvoker.SeekTo(long positionMs) ?, in void MediaManager.PlatformStop() ?, in void MediaManager.Stop() ?, in void MediaElementHandler.MapStopRequested(MediaElementHandler handler, MediaElement mediaElement, object args) File "//src/Core/src/CommandMapper.cs", line 105, col 38, in void CommandMapper<TVirtualView, TViewHandler>.Add(string key, Action<TViewHandler, TVirtualView> action)+(IElementHandler h, IElement v, object o) => { } File "//src/Core/src/CommandMapper.cs", line 29, col 4, in void CommandMapper.InvokeCore(string key, IElementHandler viewHandler, IElement virtualView, object args) File "//src/Core/src/Handlers/Element/ElementHandler.cs", line 92, col 4, in void ElementHandler.Invoke(string command, object args) ?, in void MediaElement.Stop() ?, in void AudioPlayerControl.StopAudio() ?, in void MainPage.OnStopSongPart(object sender, EventArgs e) ?, in async void SearchSongPartsView.SonglibraryListViewItemTapped(object sender, ItemTappedEventArgs e) ?, in void AsyncMethodBuilderCore.Start<d30>(ref d30) ?, in void SearchSongPartsView.SonglibraryListViewItemTapped(object sender, ItemTappedEventArgs e) ?, in bool SfListView.RaiseItemTapped(ItemTappedEventArgs e) ?, in void SelectionController.HandleTouchInteraction(TouchGesture gesture, ListViewItemInfoBase itemInfo, Point position) ?, in void ListViewItemInfoBase.HandleTouchInteraction(TouchGesture gesture, Point position) ?, in void ListViewItem.OnTap(TapEventArgs e) ?, in void GestureDetector.OnTapped(Point touchPoint, int tapCount) ?, in bool ScrollListener.OnSingleTapUp(MotionEvent e) ?, in bool SimpleOnGestureListener.n_OnSingleTapUp_Landroid_viewMotionEvent(IntPtr jnienv, IntPtr native__this, IntPtr native_e) ?, in bool JNINativeWrapper.Wrap_JniMarshal_PPL_Z(_JniMarshal_PPL_Z callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) ?, in byte JniNativeMethods.wrapper_native_indirect_byte_intptr_intptr_intptr_intptr(ref IntPtr, IntPtr, IntPtr, IntPtr, IntPtr) ?, in bool InstanceMethods.CallBooleanMethod(JniObjectReference, JniMethodInfo, JniArgumentValue) ?, in bool JniInstanceMethods.InvokeVirtualBooleanMethod(string, IJavaPeerable, JniArgumentValue) ?, in bool GestureDetector.OnTouchEvent(MotionEvent) ?, in void GestureDetector.PlatformView_Touch(object sender, TouchEventArgs e) ?, in bool IOnTouchListenerImplementor.OnTouch(View, MotionEvent) ?, in bool IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_viewMotionEvent(IntPtr jnienv, IntPtr nativethis, IntPtr native_v, IntPtr native_e) ?, in bool JNINativeWrapper.Wrap_JniMarshal_PPLL_Z(_JniMarshal_PPLL_Z callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1) ?, in byte JniNativeMethods.wrapper_native_indirect_byte_intptr_intptr_intptr_intptrintptr(ref IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr) ?, in bool InstanceMethods.CallNonvirtualBooleanMethod(JniObjectReference, JniObjectReference, JniMethodInfo, JniArgumentValue) ?, in bool JniInstanceMethods.InvokeVirtualBooleanMethod(string, IJavaPeerable, JniArgumentValue) ?, in bool Activity.DispatchTouchEvent(MotionEvent) File "//src/Core/src/Platform/Android/MauiAppCompatActivity.cs", line 47, col 4, in bool MauiAppCompatActivity.DispatchTouchEvent(MotionEvent e) ?, in bool Activity.n_DispatchTouchEvent_Landroid_viewMotionEvent(IntPtr jnienv, IntPtr nativethis, IntPtr native_ev) ?, in bool JNINativeWrapper.Wrap_JniMarshal_PPL_Z(_JniMarshal_PPL_Z callback, IntPtr jnienv, IntPtr klazz, IntPtr p0)

All the dots are all the same pointless messages, I think they get sent each time the MediaPlayer state gets updated (when its playing, pausing, stopped). Image

Expected Behavior

No more messages or fix for Android 13 and above.

Steps To Reproduce

Not entirely sure how to reproduce it. As long as the BroadCastmanager gets used on an Android device with version 13 or higher.

Link to public reproduction project repository

https://github.com/giannistek1/rpd-player/tree/main

Environment

Anything else?

The message also classifies as an error. Don't know why.

Image

ne0rrmatrix commented 3 weeks ago

Can you test your project against this PR and reply back if it solves your issue? https://github.com/CommunityToolkit/Maui/pull/2076 I am hoping to have it merged to main soon.

giannistek1 commented 14 hours ago

@ne0rrmatrix Sorry for the late reply. I do not know how to get a specific PR into my MAUI project to test the change. Is there a site or place to see how to do this? I would love to test it out and not get this many unncessary messages in Sentry.

pictos commented 9 hours ago

@giannistek1 you can download the generated nugets from here