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

Android 10 ( 29 ) is not supported - Connect to network, enable, disable and more.. #113

Closed
3 of 7 tasks
eliadAfeka opened this issue Sep 12, 2020 · 45 comments
Closed
3 of 7 tasks

Comments

@eliadAfeka
Copy link

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

some actions will not be supported in Android 10 due to some Android major upgrades in their API

Steps to Reproduce

  1. set "android-targetSdkVersion" to "29" in config.xml
  2. run your app on an Android 10 device. (it will not be reproduced if your device has <Android 10)
  3. try the following actions which will get errors:
  • Disable wifi
  • Enable wifi
  • Connect to network

Expected behavior: success

Actual behavior: Get errors

Reproduces how often: 100%

Versions

Please include the plugin version that you are using and also include the OS, version and device you are using.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

@alistans
Copy link

For me it helped setting "android-targetSdkVersion" to 28 and to manually enable GPS on the phone. Which seems to work as a workaround for now...

@eliadAfeka
Copy link
Author

it will not work for you from November 2020.

@VijayVaveHealth
Copy link

I have a working version running on Android 10. I modified it by forking https://github.com/ViggoChavine/WifiWizard2 who already started work for API 29 and i added on top of it for my app feel free to use as a base or as is: https://github.com/VijayVaveHealth/WifiWizard2/.
For ViggoChavine you have to manually call the add and enable functions. I modified my connect function slightly so you can just do WifiWizard2.connect(wifi.SSID, false, wifi.password, 'WPA')

On Android 29 there is a bug on certain devices, so far i've seen it on Oneplus 6 and a Nokia android phone the connection dialog comes up and gets stuck in a loop. If you read stackoverflow or other websites users mention seeing this on some of their devices, there is also a google issue ticket that was started but no update so far, seems phone vendors are at fault here. It works fine on the Pixel and Samsung phones.

@eliadAfeka
Copy link
Author

eliadAfeka commented Sep 26, 2020

hi,

@VijayVaveHealth - after installing your version it seems like not working while trying to connect wifi.
I get a different error from what I had, but still can't connect. I get "CONNECT_FAILED_TIMEOUT"

@VijayVaveHealth
Copy link

VijayVaveHealth commented Oct 1, 2020

@eliadAfeka i only call the WifiWizard2.connect and in my WifiWizard.js file you will see in the connect function the calls to the android code. Android 10 devices only call add and then don't do anything else.

`

             if(device.platform === "Android" && parseInt(device.version.split('.')[0]) >= 10){

                 // New method for Android Q does not support it add method already brings up dialog to join network

            } else {

                // Successfully updated or added wifiConfig

                cordova.exec(resolve, reject, "WifiWizard2", "connect", [WifiWizard2.formatWifiString(SSID), bindAll]);

            }`

@eliadAfeka
Copy link
Author

@VijayVaveHealth so I don't understand. how can I connect with Andoird>=10?

@laxman-spidey
Copy link

@VijayVaveHealth Thanks for the fix, it worked on Android 10 on my Samsung device.
There seems to be another issue, when i'm connected to other network and trying to connect to new network from the list, it's always saying "CONNECT_FAILED_TIMEOUT". It worked when i'm not connected to any wifi.
Should i disconnect before calling connect?

@eliadAfeka
Copy link
Author

@laxman-spidey it turned to be that there is no support in WPA2, just use WPA instead and it will work.

@eliadAfeka
Copy link
Author

@VijayVaveHealth can merge your commits?

@HusFNS
Copy link

HusFNS commented Nov 10, 2020

@VijayVaveHealth your branch works perfect for me. This actually also gives me a succes back and doesn't keep hanging.
But actually it doesn't give me an error.

So when the network is not available it keeps loading any fix for this?

@sephallen
Copy link

@VijayVaveHealth thanks for your work on implementing API level 29, unfortunately on Ionic 3 I receive a strange pop up saying "Searching for devices..." when I attempt to connect to a network via the connect or add method.
Eventually it will timeout giving me the option to cancel or retry. Interestingly, if I cancel, it reveals a pop up behind displaying my typical WiFiWizard2 connection message, but this never resolves.

This also happens with using the master branch of triplfex's repo which contains ViggoChavine's API 29 fixes (I have even tried other forks with API 29 support such as TMAEDCC, but I always have the same result).

I am using a Pixel 4 with Android 11.

@HusFNS
Copy link

HusFNS commented Nov 18, 2020

I also saw that a few people started working on this but actually no success.

https://github.com/Pankaja13/WifiWizard2/tree/android-29 here the issue is it keeps looping and popping up the connection box.

https://github.com/ScottWaring/WifiWizard2/tree/android-ten-test This looked promising but when I add it to my project I get lots of errors so no succes

@sephallen
Copy link

@HusFNS from what I can tell, almost all of the methods used in WifiWizard2 were deprecated. It seems that using WifiNetworkSuggestion might be the way forward now, but is only seems to support networks without an active internet connection (I assume it is intended purely for IoT).

Source: https://developer.android.com/guide/topics/connectivity/wifi-suggest#java

However, this may work in conjunction with above: https://developer.android.com/reference/android/provider/Settings?hl=en#ACTION_WIFI_ADD_NETWORKS

@sephallen
Copy link

This plugin (https://github.com/sushichop/cordova-plugin-wifi-manager) does appear to work on my Pixel 4 running Android 11, however it does not have offer functionality such as scanning for nearby networks.

For now, I can run both plugins in order to achieve my goals, put perhaps the method used in cordova-plugin-wifi-manager can help with WifiWizard2's adoption of API level 29+.

@Pankaja13
Copy link

@HusFNS That fork was really intended for a specific project I am working on but there's no reason it shouldn't work. I did have trouble getting that promise returned on success so I added a less than perfect workaround. Here's how I'm using in on > Android 10:

WifiWizard2.connect("SSID", true, "Password", "WPA").catch((e) => {
	if (e.toString() === "onUnavailable"){
		// Failure (or user clicked cancelled)
	}
	WifiWizard2.getConnectedSSID().then((SSID) => {
		// Success
	})
});

@sephallen
Copy link

@HusFNS That fork was really intended for a specific project I am working on but there's no reason it shouldn't work. I did have trouble getting that promise returned on success so I added a less than perfect workaround. Here's how I'm using in on > Android 10:

WifiWizard2.connect("SSID", true, "Password", "WPA").catch((e) => {
	if (e.toString() === "onUnavailable"){
		// Failure (or user clicked cancelled)
	}
	WifiWizard2.getConnectedSSID().then((SSID) => {
		// Success
	})
});

I can confirm this works with Ionic 3 on a Pixel 4 with Android 11 - thanks!

@HusFNS
Copy link

HusFNS commented Nov 26, 2020

I have been working on a fix and can be tested. It works fine for me on my android 10 (samsung).

The reason why he doesn't always return onUnavailable is because it is a bug in android. I made a workaround with a timout.
The available now returns success

@shivam-sagar19
Copy link

Hi, I was facing same issue on my device OnePlus 6T with Android 10 and i wasn't able to connect through selected ssid.
So after 2-3 days i got to know that you have to turn on your GPS before connecting to wifi network. And this method works for me Hopefully this will work for you as well.

@KinG-InFeT
Copy link

possible android issue? https://issuetracker.google.com/issues/158344328

@alistans
Copy link

I'm able to connect to networks now again thanks to @maxcodefaster's fork, thank you!

But is it correct the wi-fi doesn't automatically turn on anymore if it's turned off? Does anybody know if there is a way to still programatically turn on wi-fi?

@HusFNS
Copy link

HusFNS commented Dec 16, 2020

@KinG-InFeT this was indeed what I said. That's why I used the workaround with the de timeout.

I see @maxcodefaster used my fix and made a merge request for the master branch.

@maxcodefaster
Copy link
Contributor

Yes MR is inspired by @HusFNS

@1x2x3x4x
Copy link

I'm able to connect to networks now again thanks to @maxcodefaster's fork, thank you!

But is it correct the wi-fi doesn't automatically turn on anymore if it's turned off? Does anybody know if there is a way to still programatically turn on wi-fi?

How do you do it?
I'm doing it like this and I get WiFi not available

WifiWizard2.connect("myssid", true, "", "", false)
      .then((data) => {

      })
      .catch(async (error) => {          

     
      });

@KinG-InFeT
Copy link

yes, i use this commit

@KinG-InFeT this was indeed what I said. That's why I used the workaround with the de timeout.

I see @maxcodefaster used my fix and made a merge request for the master branch.

yes, i use the new fix with timeout but out UnAvailable, i tried add more timeout but not work. My device is Samsung Tab S6 Lite Android 10

@KinG-InFeT
Copy link

I'm able to connect to networks now again thanks to @maxcodefaster's fork, thank you!
But is it correct the wi-fi doesn't automatically turn on anymore if it's turned off? Does anybody know if there is a way to still programatically turn on wi-fi?

How do you do it?
I'm doing it like this and I get WiFi not available

WifiWizard2.connect("myssid", true, "", "", false)
      .then((data) => {

      })
      .catch(async (error) => {          

     
      });

yes, same error

@KinG-InFeT
Copy link

the PR is #115

@alistans
Copy link

Like this @KinG-InFeT and @1x2x3x4x

WifiWizard2.connect(SSID, true, password, 'WPA').then((success) => {
       ...
    }).catch((error) => {
        ...
    });

@KinG-InFeT
Copy link

Like this @KinG-InFeT and @1x2x3x4x

WifiWizard2.connect(SSID, true, password, 'WPA').then((success) => {
       ...
    }).catch((error) => {
        ...
    });

yes, this is my code

WifiWizard2.connect(ssid, true, password, algorithm, false).then(() => {
                                    app.dialog.alert('Connessione riuscita');
                                }).catch((error) => {
                                    console.warn(error);
                                    app.dialog.close();
                                    var errMsg = error && error.message ? error.message : error;
                                    app.dialog.alert(errMsg);
                                });

(use framework7 latest version)

@KinG-InFeT
Copy link

i found this project and work perfectly on my table with android 10: https://github.com/Tasssadar/RequestNetworkRepro but write in Kotlin

@gregor-srdic
Copy link

Did anyone encounter the following errors on Android 10?

I/WifiService: addOrUpdateNetwork not allowed for uid=10773
I/WifiService: getConfiguredNetworks not allowed for uid=10773
E/WifiService: 10164 has no permission about LOCAL_MAC_ADDRESS

https://github.com/sushichop/cordova-plugin-wifi-manager seems to work though, what could be the difference?

@1x2x3x4x
Copy link

I've finally managed to get it to work like this on Android 10, Samsung s20 and a Samsung tablet. No luck on One Plus 5T but that's their fault, not the plugin's. I've used maxcodefaster's repo.

WifiWizard2.connect('mySSID', true, '', 'WPA').catch((e) => {
    if (e.toString() === "onUnavailable") {
        alert(e.toString())
    }
    WifiWizard2.getConnectedSSID().then((SSID) => {
        alert(SSID)
    })
});

However for some reason it won't work on a Xiaomi with Android 9.

@joeyousef
Copy link

I am having the same problem tried WifiWizard2.connect not working on Android 10 (APK-29), it is working fine on APK-28.
I am using Ionic 3 this is my implementation.

`declare var WifiWizard2: any;

  WifiWizard2.connect("ssid", true, "password", "WPA").catch((e) => {
    if (e.toString() === "onUnavailable"){
        this.perror = e.toString();
      // Failure (or user clicked cancelled)
    }
    WifiWizard2.getConnectedSSID().then((SSID) => {
      // Success
      this.pdone = JSON.stringify(SSID);
    })

`
any help ?

@joeyousef
Copy link

I have the fine location permission also, but I can't grant background permission

this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.ACCESS_FINE_LOCATION);

@joeyousef
Copy link

joeyousef commented Jan 14, 2021

it appears that my problem is with Ioinc 3 and android core as I understand if anyone could make it work or have a solution for that please let me know.

this is my project's android version
<engine name="android" spec="~7.1.4" />

this is the error while building
ifiWizard2.java:44: error: cannot find symbol import android.net.wifi.WifiNetworkSpecifier; ^

@arsenal942
Copy link
Collaborator

Hello children for I have returned.

I have merged PR #115 (there needs to be one or two changes since I was a bit gun-hoe on the merge).

@xLarry
Copy link
Contributor

xLarry commented Jan 15, 2021

@arsenal942 I'm excited to see this finally merged, thank you!! 😍

I am wondering if changing the URL of the repository in package.json and plugin.xml (see https://github.com/tripflex/WifiWizard2/pull/115/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R13) is intended? 🤔

@arsenal942
Copy link
Collaborator

arsenal942 commented Jan 15, 2021 via email

arsenal942 added a commit that referenced this issue Jan 17, 2021
Fixing up the changes from PR #113
@arsenal942
Copy link
Collaborator

@xLarry I have fixed it

@arsenal942
Copy link
Collaborator

This has finally been merged and therefore can be closed :)

@Amr-Sherif
Copy link

I have a working version running on Android 10. I modified it by forking https://github.com/ViggoChavine/WifiWizard2 who already started work for API 29 and i added on top of it for my app feel free to use as a base or as is: https://github.com/VijayVaveHealth/WifiWizard2/.
For ViggoChavine you have to manually call the add and enable functions. I modified my connect function slightly so you can just do WifiWizard2.connect(wifi.SSID, false, wifi.password, 'WPA')

On Android 29 there is a bug on certain devices, so far i've seen it on Oneplus 6 and a Nokia android phone the connection dialog comes up and gets stuck in a loop. If you read stackoverflow or other websites users mention seeing this on some of their devices, there is also a google issue ticket that was started but no update so far, seems phone vendors are at fault here. It works fine on the Pixel and Samsung phones.

I am having the same loop issue on Android 29 on my Oneplus 6t, it connects for a second and then disconnects again.
Any updates regarding this?

@1x2x3x4x
Copy link

I am having the same loop issue on Android 29 on my Oneplus 6t, it connects for a second and then disconnects again.
Any updates regarding this?

That error has nothing to do with the plugin. It's your OS's fault. You can go and read about it on OnePlus'es forums.

Just google 'oneplus WifiNetworkSpecifier'.

You'll just have to wait and see if any future update from oneplus will fix it.

@jainsuneet
Copy link

I'm able to connect to networks now again thanks to @maxcodefaster's fork, thank you!
But is it correct the wi-fi doesn't automatically turn on anymore if it's turned off? Does anybody know if there is a way to still programatically turn on wi-fi?

How do you do it?
I'm doing it like this and I get WiFi not available

WifiWizard2.connect("myssid", true, "", "", false)
      .then((data) => {

      })
      .catch(async (error) => {          

     
      });

Did you find any solution for 'WiFi not available' ? I am getting the same error. I am currently using master branch on android 10.

@Ravipsg1w
Copy link

Did you find any solution for 'WiFi not available' ? I am getting the same error. I am currently using master branch on android 10 OnePlus

@1x2x3x4x
Copy link

I stoppped using this in my projects. I'm using Capacitor and works so far on the latst versions of Android and iOS: https://github.com/digaus/community-capacitor-wifi

@Nitin-Tankup
Copy link

So the solution is simply adding location permission to the app. You can ask for it from the app, or you can test it by going to your app settings -> permissions -> location and clicking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests