xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 506 forks source link

[Bug] Essentials connectivity - Android 14 Crash - java.lang.SecurityException:One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts(API level 34)[Bug] #2107

Closed pasha-o closed 7 months ago

pasha-o commented 8 months ago

Description

targeting Api 34 and the emulator - running the Xamarin app with the essential connectivity.

[mono-rt] at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue args) [0x00068] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/JniEnvironment.g.cs:11524 [mono-rt] at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue parameters) [0x00036] in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:867 [mono-rt] at Android.Content.ContextWrapper.RegisterReceiver (Android.Content.BroadcastReceiver receiver, Android.Content.IntentFilter filter) [0x00049] in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Android.Content.ContextWrapper.cs:2464 [mono-rt] at Xamarin.Essentials.Connectivity.StartListeners () [0x00045] in D:\a_work\1\s\Xamarin.Essentials\Connectivity\Connectivity.android.cs:37 [mono-rt] at Xamarin.Essentials.Connectivity.add_ConnectivityChanged (System.EventHandler`1[TEventArgs] value) [0x0001c] in D:\a_work\1\s\Xamarin.Essentials\Connectivity\Connectivity.shared.cs:31

Steps to Reproduce

Reproduction Link

LucaZiegler commented 8 months ago

Same issue when using Xamarin.Essentials.Connectivity.ConnectivityChanged on Android 14.

Java.Lang.SecurityException: ' One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts'

LucaZiegler commented 8 months ago

Same issue as in MAUI: https://github.com/dotnet/maui/issues/17861

jfversluis commented 8 months ago

Would you be able to retrieve the artifacts produced by this PR: https://github.com/xamarin/Essentials/pull/2108 and see if that fixes your issue?

This should be a direct link: https://dev.azure.com/xamarin/6fd3d886-57a5-4e31-8db7-52a1b47c07a8/_apis/build/builds/102499/artifacts?artifactName=nuget&api-version=7.1&%24format=zip

LeoJHarris commented 7 months ago

@jfversluis I have tested 1.8.0-pr.2108.1 and it worked fine for me.

jfversluis commented 7 months ago

Thank you @LeoJHarris !

Larhei commented 7 months ago

backport to net7?

abdul-wasey commented 7 months ago

@jfversluis how can I get this fix for xamarin.forms ? I'm not able to see this version "1.8.0-pr.2108.1" in NPM which is mentioned by @LeoJHarris. could you please help me here. Thanks!

Note: I have tried Nightly Feeds but it's not public. ( https://aka.ms/xamarin-essentials-ci/index.json )