fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.5k stars 881 forks source link

NetworkInfo().getWifiName(); gives null instead of Actual WiFi SSID in Android 14 #3022

Open BTree-dev1 opened 3 weeks ago

BTree-dev1 commented 3 weeks ago

Platform

Android 14

Plugin

network_info_plus

Version

5.0.3

Flutter SDK

3.19.6

Steps to reproduce

I have connected to WiFI Jarvis which have good internet connection.... When Look for that SSID using this package getting null

I have tried in the Other WiFiIOT package too that gives me

Code Sample

if (await Permission.locationWhenInUse.request().isGranted) {
                          // Check if connected to WiFi
                          var connectivityResult = await (Connectivity().checkConnectivity());
                          log("ConnectivityResult====> $connectivityResult");
                          var _net = NetworkInfo();
                          String? ssid = await _net.getWifiName();
                          log("SSID: $ssid");
                          if (connectivityResult[0] != ConnectivityResult.wifi) {
                            log("Wificonectionn====> false");
                          } else {
                            log("Wificonectionn====> true");
                            // Try to get the current WiFi SSID
                            String? currentWifi = await WiFiForIoTPlugin.getSSID();
                            log("SSID: $currentWifi");
                            if (currentWifi == "Jarvis") {
                              log("Device connected to Jarvis Wi-Fi!");
                            } else {
                              log("Device not connected to Jarvis Wi-Fi.");
                            }
                          }
                        } else {
                          log("Location permission denied");
                        }

Logs

[log] ConnectivityResult====> [ConnectivityResult.wifi]
[log] SSID: null
[log] Wificonectionn====> true
[log] SSID: <unknown ssid>
[log] Device not connected to Jarvis Wi-Fi.

Flutter Doctor

[✓] Flutter (Channel stable, 3.19.6, on macOS 14.3.1 23D60 darwin-arm64, locale en-IN)
• Flutter version 3.19.6 on channel stable at /Users/veerasivaraman/Documents/fluttersdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (7 weeks ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/veerasivaraman/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.84.2)
• VS Code at /Users/veerasivaraman/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.90.0

[✓] Connected device (4 available)
• SM E045F (mobile) • R9ZW90BCNHY • android-arm64 • Android 14 (API 34)
• iPad Pro (11-inch) (4th generation) (mobile) • D9078B58-9458-48A3-9898-C8EF4EEA128F • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.3.1 23D60 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 125.0.6422.141
! Error: Browsing on the local area network for iPhone 4. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for iPhone 1. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
! Error: Browsing on the local area network for iPhone 2. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
• All expected network resources are available.

• No issues found!

Checklist before submitting a bug

miquelbeltran commented 2 weeks ago

I am not able to fully understand your explanation.

For what I can see, network_info_plus returns null as SSID. What is the other plugin WiFiForIoTPlugin.getSSID() returning you? From your log it says <unknown ssid>, which doesn't look good either.

Do you have

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

in your Android manifest?

BTree-dev1 commented 2 weeks ago

Yes I have ACCESS_FINE_LOCATION permission in manifest. Even though I didn't get the SSID. I tried network_info_plus package first that gives me null, After that I tried wifi_iot packages that too give me <unknown ssid> But When I this android:requestLegacyExternalStorage="true" in my manifest I'm able to get the SSID.

Is this a correct fix ?

miquelbeltran commented 2 weeks ago

That's so weird :)

I have no idea why would the storage permissions affect the WIFI name permissions.

Bheck890 commented 2 weeks ago

I get the same issue, i am working on an old tablet, and it also does not work, I even added the storage permission and it did not work.

also why are all the tests failing in the action area. for network info plus

miquelbeltran commented 2 weeks ago

also why are all the tests failing in the action area. for network info plus

Can you specify which tests exactly?

Integration tests are flaky due to emulator taking too long to start on GitHub Actions.

miquelbeltran commented 2 weeks ago

I just ran the example app on my device, and it works for me, I can see the Wi-Fi Name, BSSID, etc.

Can you try with the example app in the repo, as provided, and see if you get the same results?

Bheck890 commented 2 weeks ago

i tried again, just found out the location permission was not enabled, for that specific app, sorry

so this actions error list is normal? https://github.com/fluttercommunity/plus_plugins/actions/workflows/network_info_plus.yaml

miquelbeltran commented 2 weeks ago

so this actions error list is normal? https://github.com/fluttercommunity/plus_plugins/actions/workflows/network_info_plus.yaml

Depends on the job. Like I said, many of the integration_test runs on Android fail because of the emulator starting issues.

If there is a specific job you would like to know more, let me know.

Otherwise, I'd ask you to keep a positive and professional attitude when interacting with the team.