"Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged" will raise exception on android14

Fei Xu 490 Reputation points
2024-01-03T04:21:11.2966667+00:00

.net 8 android14 "Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged" will raise exception

android13 , android 12 run well no exception.

User's image

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2024-01-04T06:24:13.8033333+00:00

    Hello,

    It appears to be a bug. And this issue has been reported it at MAUI github repo, please see:Adding a Connectivity.ConnectivityChanged handler throw an exception on Android 14 #17861

    This issue has been fixed, but New .NET MAUI version do not been released. Please track on this issue by above github link.

    By the way, here is a workaround, you can change the android target-framework to android 13 manually, this issue will disappear when you run it in android 14 devices or emulator. Open you AndroidManifest.xml file, add <uses-sdk android:targetSdkVersion="33" /> in the <manifest > tag like following simple code.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
        <application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true"></application>
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />
    
    add here
        <uses-sdk android:targetSdkVersion="33" />
    </manifest
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Ravi Nalla 126 Reputation points
    2024-04-05T09:08:02.88+00:00

    Any other solution without changing targetsdkversion ?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.