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 - SDK android-targetSdkVersion <= 28 #121

Closed
3 of 7 tasks
klich3 opened this issue Feb 16, 2021 · 20 comments
Closed
3 of 7 tasks

Android - SDK android-targetSdkVersion <= 28 #121

klich3 opened this issue Feb 16, 2021 · 20 comments

Comments

@klich3
Copy link

klich3 commented Feb 16, 2021

Prerequisites

Check all boxes if you have done the following:

Issue type

Select all that apply

  • Bug
  • Enhancement
  • Task
  • Question
  • Other

Description

On Android this plugin is working with android-targetSdkVersion <= 28. When compile phone gap with Api 29.
Currently for upload your app to G-Play is requiered Api version 29 and above.

@matteocappello94
Copy link

Please install it with cordova plugin add https://github.com/tripflex/WifiWizard2 or ionic cordova plugin add https://github.com/tripflex/WifiWizard2 if you are using Ionic framework.

NPM release is older than GitHub master repository and there isn't Android 10 support on it.

@klich3
Copy link
Author

klich3 commented Feb 18, 2021

You have one pull request for add new method for support Android 10. See it and, add it if you wanna...
Regards

@jainsuneet
Copy link

Please install it with cordova plugin add https://github.com/tripflex/WifiWizard2 or ionic cordova plugin add https://github.com/tripflex/WifiWizard2 if you are using Ionic framework.

NPM release is older than GitHub master repository and there isn't Android 10 support on it.

@klich3 @matteocappello94 I am using the current master version and I still get an error 'WiFi not available' on connect()

@matteocappello94
Copy link

matteocappello94 commented Feb 26, 2021

Please install it with cordova plugin add https://github.com/tripflex/WifiWizard2 or ionic cordova plugin add https://github.com/tripflex/WifiWizard2 if you are using Ionic framework.
NPM release is older than GitHub master repository and there isn't Android 10 support on it.

@klich3 @matteocappello94 I am using the current master version and I still get an error 'WiFi not available' on connect()

Target Android 10, WifiWizard2 can't enable Wifi interface if it's disabled. To use it Wifi interface needs to be on.
https://developer.android.com/about/versions/10/privacy/changes#enable-disable-wifi

@jainsuneet
Copy link

Please install it with cordova plugin add https://github.com/tripflex/WifiWizard2 or ionic cordova plugin add https://github.com/tripflex/WifiWizard2 if you are using Ionic framework.
NPM release is older than GitHub master repository and there isn't Android 10 support on it.

@klich3 @matteocappello94 I am using the current master version and I still get an error 'WiFi not available' on connect()

Target Android 10, WifiWizard2 can't enable Wifi interface if it's disabled. To use it Wifi interface needs to be on.
https://developer.android.com/about/versions/10/privacy/changes#enable-disable-wifi

@matteocappello94 The Wifi interface is on. It works without any issue on targetsdk 28 but with 29 it is throwing error 'WiFi not available'. Event location access is also provided.

@matteocappello94
Copy link

@jainsuneet I'm using this version https://github.com/cloudsurfers-it/WifiWizard2/tree/plus (fork of this master with some little improvement for my work) targeting API 29 and Cordova without any problems.
Post a snipped of your code please.
Are you sure you have updated correctly the plugin? try to remove it with cordova plugin rm wifiwizard2 and re-install it from this repository master or from my "plus" branch.

@jainsuneet
Copy link

https://github.com/cloudsurfers-it/WifiWizard2/tree/plus

@matteocappello94 With your version I am getting below error while installing

cordova plugin add https://github.com/cloudsurfers-it/WifiWizard2/tree/plus

Failed to fetch plugin https://github.com/cloudsurfers-it/WifiWizard2/tree/plus via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
CordovaError: Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOPACKAGEJSON
npm ERR! package.json Non-registry package missing package.json: https://github.com/cloudsurfers-it/WifiWizard2/tree/plus.
npm ERR! package.json npm can't find a package.json file in your current directory.

Here is the snippet of my code to connect to the WiFi

window.WifiWizard2.connect('SSID_Name', true).then((data) => {
    alert(JSON.stringify('success'))
}).catch((error) => {
    alert(JSON.stringify(error))
})

@matteocappello94
Copy link

@jainsuneet when you install from GitHub cordova plugin add https://github.com/cloudsurfers-it/wifiwizard2.git#plus #{branch-name} to select a branch.

@jainsuneet
Copy link

cordova plugin add https://github.com/cloudsurfers-it/wifiwizard2.git#plus

@matteocappello94 With your repo is also the same error 'WiFi not available'

@matteocappello94
Copy link

@jainsuneet with Android Studio, you can debug with breakpoints .java class and methods of WifiWizard2 to verify where error occur.
Try to pass all args to the connect method, for example:
WifiWizard2.connect("NETWORK_NAME", true, "12345678", "WPA", false, true)
last argument withPattern it's only present on my "plus" branch. Let you list on Android 10 Wifi connection popup multiple networks, which are selected with RegEx pattern.

@matteocappello94
Copy link

matteocappello94 commented Feb 26, 2021

@jainsuneet LOCATION permission is granted, but location interface is enabled?

@jainsuneet
Copy link

@jainsuneet LOCATION permission is granted, but location interface is enabled?

@matteocappello94 yes location interface is also enabled and also I cannot pass others args because the wifi is an open network.

@matteocappello94
Copy link

@jainsuneet WIFI_NOT_ENABLED returned from verifyWifiEnabled() method of WifiWizard2.java
This method call wifiManager.isWifiEnabled() to check Wifi interface state. You have to debug this method with Android Studio to find your error on your device. If you are using Cordova, open Android project directly with Android Studio.

@jainsuneet
Copy link

@jainsuneet WIFI_NOT_ENABLED returned from verifyWifiEnabled() method of WifiWizard2.java
This method call wifiManager.isWifiEnabled() to check Wifi interface state. You have to debug this method with Android Studio to find your error on your device. If you are using Cordova, open Android project directly with Android Studio.

@matteocappello94 I am getting 'WiFi not available', I can scan for the wifi ssids and it works but the connection is failing.

The not available is coming from

public void onUnavailable() {
    super.onUnavailable();
    Log.d(TAG, "WiFi not available");
    callbackContext.error("WiFi not available");
}

which is within if(API_VERSION >= 29) block

@matteocappello94
Copy link

@jainsuneet appear popup window when you try to connect? If you can try with a Wifi network with password using method with all args like this:
WifiWizard2.connect("NETWORK_NAME", true, "12345678", "WPA", false, true)
This works for me without any problems.
I've to try to connect to an open network to check if the problem still also present with my app or not.

@jainsuneet
Copy link

jainsuneet commented Mar 1, 2021

@jainsuneet appear popup window when you try to connect? If you can try with a Wifi network with password using method with all args like this:
WifiWizard2.connect("NETWORK_NAME", true, "12345678", "WPA", false, true)
This works for me without any problems.
I've to try to connect to an open network to check if the problem still also present with my app or not.

@matteocappello94 Yes now I tried with Password as well.
WifiWizard2.connect("NETWORK_NAME", true, "12345678", "WPA", false, true)

Still it throws the same error 'WiFi not available'. Even I am getting the popup with Wifi Network details but after that comes the error.

But if I connect like this WifiWizard2.connect("NETWORK_NAME", true, "12345678", "WPA", false) then it works:

Is there any way that I can connect to an open WiFi? it will be really helpful.

@klich3
Copy link
Author

klich3 commented Mar 1, 2021

You can try connect to specify network knowing SSID and Pass. Try new method.

Maybe solve your problem.

https://github.com/klich3/WifiWizard2#dev

@jainsuneet
Copy link

You can try connect to specify network knowing SSID and Pass. Try new method.

Maybe solve your problem.

https://github.com/klich3/WifiWizard2#dev

@klich3 So I finally found the issue that why it was not able to connect to an open network. builder.setWpa2Passphrase(newPass); is the standard wpa2 connection. If I disable this line then open network connection works. Other functions like disconnect and remove are not at all working for API >= 29.

@klich3
Copy link
Author

klich3 commented Mar 2, 2021

You can try connect to specify network knowing SSID and Pass. Try new method.
Maybe solve your problem.
https://github.com/klich3/WifiWizard2#dev

@klich3 So I finally found the issue that why it was not able to connect to an open network. builder.setWpa2Passphrase(newPass); is the standard wpa2 connection. If I disable this line then open network connection works. Other functions like disconnect and remove are not at all working for API >= 29.

Thanks, now for default is set as NONE for Open networks. Others Methods are Depricated on >= Api 29

@klich3 klich3 closed this as completed May 6, 2021
@jainsuneet
Copy link

You can try connect to specify network knowing SSID and Pass. Try new method.
Maybe solve your problem.
https://github.com/klich3/WifiWizard2#dev

@klich3 So I finally found the issue that why it was not able to connect to an open network. builder.setWpa2Passphrase(newPass); is the standard wpa2 connection. If I disable this line then open network connection works. Other functions like disconnect and remove are not at all working for API >= 29.

Thanks, now for default is set as NONE for Open networks. Others Methods are Depricated on >= Api 29

@klich3 With your latest commit on the dev branch I am getting lot of errors and the build is getting failed. Can you please help to resolve the issue.

> Task :app:compileDebugJavaWithJavac FAILED
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2008: error: empty character literal
        if(Algorithm.matches("/WPA3/gim") && PASS != '')
                                                     ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2008: error: unclosed character literal
        if(Algorithm.matches("/WPA3/gim") && PASS != '')
                                                      ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2008: error: ';' expected
        if(Algorithm.matches("/WPA3/gim") && PASS != '')
                                                        ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:1988: error: 'try' without 'catch', 'finally' or resource declarations
      try {
      ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2056: error: 'catch' without 'try'
      } catch (Exception e) {
        ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2060: error: illegal start of type
    }else{
     ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2060: error: ';' expected
    }else{
         ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2061: error: <identifier> expected
      callbackContext.error("SPECIFIER_INVALID_API_VERSION");
                           ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2061: error: illegal start of type
      callbackContext.error("SPECIFIER_INVALID_API_VERSION");
                            ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2062: error: <identifier> expected
      Log.d(TAG, "WifiWizard2: 211 - specifierConnection invalid Android API Version is below as needed.");
           ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2062: error: <identifier> expected
      Log.d(TAG, "WifiWizard2: 211 - specifierConnection invalid Android API Version is below as needed.");
               ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2062: error: illegal start of type
      Log.d(TAG, "WifiWizard2: 211 - specifierConnection invalid Android API Version is below as needed.");
                 ^
App\src-cordova\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:2064: error: class, interface, or enum expected
  }
  ^
13 errors
```

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

3 participants