Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manifest error #1

Open
vincevargadev opened this issue Apr 3, 2019 · 7 comments
Open

Manifest error #1

vincevargadev opened this issue Apr 3, 2019 · 7 comments
Labels
docs Documentation must be improved

Comments

@vincevargadev
Copy link
Member

I had to manually add this permission to my app's manifest:

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

Without that, I received:

E/MethodChannel#eng.smaho.com/android_wifi_info(15758): Failed to handle method call
E/MethodChannel#eng.smaho.com/android_wifi_info(15758): java.lang.SecurityException: WifiService: Neither user 10136 nor current process has android.permission.ACCESS_WIFI_STATE.
@neelu004
Copy link

I am getting the await AndroidWifiInfo.ssid and await AndroidWifiInfo.macAddress as null when running on device Oneplus5T, Samsung, Redme Note5 PRO. Please suggest some solution.

@vincevargadev
Copy link
Member Author

The macAddress == null is, unfortunately, expected on most modern phones.

Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs - source

As this plugin is just a wrapper around the WifiInfo class around Android, this limitation will continue to persist.

See the docs for more info.

@vincevargadev
Copy link
Member Author

Regarding the SSID. I'm planning to solve this issue within the plugin, but in case you need a quick solution, you can try it on your own. Here are some guidelines. It's probably another permission issue.

First of all, check if the phones are connected via WiFi. I assume you checked it already and there's an issue with a plugin.

Please let me know if the issue persists. In case one of my recommendations helped, please leave a comment, it'll help others to solve their issues until I get to fix the issue (and it'll also help me fix the problem on a "plugin" level so that we automatically request the proper permissions on runtime)

@neelu004
Copy link

Hi, I have tried all the above solution but still I am getting the "AndroidWifiInfo.macAddress as null" when I am using the "android_wifi_info" dependency but when I am using the wifi_info as the dependency in flutter i am getting error while importing the package"
import 'package:wifi_info/wifi_info.dart';" and its showing like Target of URI doesn't exists "package:wifi_info/wifi_info.dart'" (mentioned above) while using flutter as the programming language and running the application on android device.
Please suggest some better solution for the same.

@vincevargadev
Copy link
Member Author

Could you fix the SSID issue? Which alternative solution fixed your issue finally?

As I tried to say, the macAddress will most likely be null on most devices. Since Android 6.0, it doesn't return a valid value which the library converts to null (as it's a non-valid value).

You can create the wifi_info.dart file yourself, it's not part of the package. Good point though, I'm going to improve the docs

@vincevargadev
Copy link
Member Author

If you receive nulls for the WiFi BSSID, you can request permissions for location, then try again.

There are multiple plugins out there that let you request permissions from the host, one I used is: https://pub.dartlang.org/packages/permission_handler

# pubspec.yaml
dependencies:
  # ... your other dependencies ...
  permission_handler: ^3.0.1

You can request permissions like:

await PermissionHandler().requestPermissions([PermissionGroup.location]);

Once you asked for these permissions, this plugin should be able to receive the WiFi BSSID and SSIDs

@vincevargadev
Copy link
Member Author

On modern Android devices, requesting permissions runtime for the location should solve the issue for WiFi BSSID.

The MAC address being null is pretty much a restriction from the Android platform, AFAIK, there is not much we can do.

In my opinion, we can close this issue, once these issues are documented better.

@neelu004 Let me know if asking permissions runtime solve your problem with the WiFi BSSID.

@vincevargadev vincevargadev added the docs Documentation must be improved label May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation must be improved
Projects
None yet
Development

No branches or pull requests

2 participants