question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.scan() not working on Android 9

See original GitHub issue

<!–

Have you read the plugins’ Code of Conduct? By creating an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/tripflex/wifiwizard2/blob/master/CODE_OF_CONDUCT.md

–>

Possibly related to #44

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

Have been using WifiWizard previously, and now WifiWizard2 (version 3.1.0) in an Ionic app publishing to Android. We’re really only using it for the .scan() and .getConnectedSSID() methods. Both work well on Android 8.1 and below. But on our tests on Android 9 (via the Google Pixel 2 XL), they always fail via timeout. Here are the logs for one attempt at .scan():

09-06 11:18:36.995 6301-6423/com.x.y.z D/WifiWizard2: WifiWizard2: verifyWifiEnabled entered.
09-06 11:18:36.995 6301-6423/com.x.y.z V/WifiWizard2: Entering startScan
09-06 11:18:36.997 6301-6423/com.x.y.z V/WifiWizard2: Submitting timeout to threadpool
09-06 11:18:36.998 6301-6423/com.x.y.z V/WifiWizard2: Registering broadcastReceiver
09-06 11:18:36.998 6301-6424/com.x.y.z V/WifiWizard2: Entering timeout
09-06 11:18:36.999 6301-6423/com.x.y.z V/WifiWizard2: Scan failed
09-06 11:18:47.000 6301-6424/com.x.y.z V/WifiWizard2: Thread sleep done
09-06 11:18:47.005 6301-6424/com.x.y.z V/WifiWizard2: In timeout, error

The thing that sticks out to me is that “Scan failed” gets logged .005 seconds after the request starts. That would seem to be triggered by these lines in the plugin (326-330):

if (!wifiManager.startScan()) {
      Log.v(TAG, "Scan failed");
      callbackContext.error("SCAN_FAILED");
      return false;
    }

Android 9 has deprecated this method in WifiManager, it’s true, and introduced some new wifi scanning throttling, detailed here: https://developer.android.com/guide/topics/connectivity/wifi-scan#wifi-scan-restrictions

However I don’t think it’s been removed entirely. And I’m not getting throttling behavior, I’m getting immediate failure, as if that method doesn’t even exist.

Any thoughts or assistance appreciated. I’ll keep working on it.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
simonkincaidkintronixcommented, Jan 25, 2019

@jameskane05 If you want to use the scan on later android devices, you have to enable GPS unfortunately. Try that to see if that fixes your problem. I believe this was a bad Google decision.

0reactions
jainsuneetcommented, Sep 2, 2019

This issue still exists in Android 9. The location is not enabled by default which leads to SCAN_FAILED error. If manually enabled the GPS then it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ScanWedge is not working in Android 9 in Standard mode ...
Android 9 does not focus automatically the input field? Scanning does not work in my app, tapping into the filed is needed first?...
Read more >
Wi-Fi scanning overview - Android Developers
Request a scan using WifiManager.startScan() . Make sure to check the return status of the method, since the call may fail for any...
Read more >
Google Barcode Scanning ML kit not working for android 8.1 ...
The app works completely fine for Android 9 (Api level 28) and above. The app works fine for all versions while scanning using...
Read more >
BLE Android 9 - Scanning stops when screen turned off - B4X
We have noticed that on Android 9 when the screen is turned off no more Scan_Result events are fired, and when the screen...
Read more >
How to Scan QR Codes with Android Phone
You will see a pop-up notification to view the QR Code details. Tap on it to view the content on the default browser...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found