kirillzyusko / react-native-wifi-p2p

Library that provide access for working with wi-fi direct (p2p) module in android.
174 stars 32 forks source link

App crashes during Get Connection Info #5

Closed sushanthNiveus closed 5 years ago

sushanthNiveus commented 5 years ago

Looks like there is an issue in WiFiP2PManagerModule. Also, the getAvaibleDevices method returns an empty array. I with Mi A1 and Xiomi Poco F1.

FATAL EXCEPTION: main Process: com.examples, PID: 11146 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.net.InetAddress.getHostAddress()' on a null object reference at io.wifi.p2p.WiFiP2PManagerModule$1.onConnectionInfoAvailable(WiFiP2PManagerModule.java:63) at android.net.wifi.p2p.WifiP2pManager$Channel$P2pHandler.handleMessage(WifiP2pManager.java:822) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:172) at android.app.ActivityThread.main(ActivityThread.java:6590) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

kirillzyusko commented 5 years ago

@sushanthNiveus Hi! You should call getConnectionInfo only after connection establishing. In other case you will get native error. I can add check for this case and reject promise or return null. But it does not solve the situation. I would like to recommend you to try at first establish connection via Setting->WiFi->Advance Settings->Wi-Fi Direct. And see result. If your device will see each other, then try again find each other via application with this library.

kirillzyusko commented 5 years ago

@sushanthNiveus But you're right. Calling this method shouldn't break application. So I've edited seeral lines of code and published it to npm (0.6.5 version). You can check it and write here, if you have any questions or this error appears again :)