Skip to content

scanNetworks() throwing PlatformException on Android 11 Samsung A52 #15

@aschaepper

Description

@aschaepper

Hello together

This could be related to this: #10 but I'm not sure and im getting a different type of exception, a "PlatformException".

I dig a bit deeper and found that it the error most probably comes from WifiManager.StartScan()
https://developer.android.com/reference/android/net/wifi/WifiManager#startScan()
Location in Code:
https://github.com/weplenish/flutter-plugins/blob/master/wifi_flutter/android/src/main/kotlin/com/weplenish/wifi_flutter/WifiFlutterPlugin.kt#L59

First I thought its because of the deprecation of this method and its not possible at all but I also use this Flutter library:
https://github.com/weplenish/flutter_wifi_connect
https://pub.dev/packages/flutter_wifi_connect

And the code here which also uses StartScan from WifiManager works (From the flutter library: FlutterWifiConnect.connectByPrefix)
https://github.com/weplenish/flutter_wifi_connect/blob/main/android/src/main/kotlin/com/weplenish/flutter_wifi_connect/FlutterWifiConnectPlugin.kt#L217

To me it looks very similar (just read through it in github, I couldn't debug it directly). So I'm not sure where the error is (I cant imagine its from the suppressed lints and deprecation messages?). Maybe for you this is a bit easier to spot?

I'm using Android 11 on a Samsung A52 here it doesnt work.
On a Huawai P9 with Android 7 it works.

Maybe this helps you to find this or even the other errors?

Unfortunately I can't fix it myself at the moment, I'm freelancing and encountered this problem in a project for the customer, we have kind of a tight budget and schedule so I will weasel around the problem instead of fixing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions