cometchat / chat-sdk-android

Text Chat SDK for Android
https://www.cometchat.com
22 stars 12 forks source link

[2.0.0-beta4] Fatal Exception: java.lang.NullPointerException Attempt to invoke virtual method 'void org.jivesoftware.smack.AbstractXMPPConnection.addAsyncStanzaListener(org.jivesoftware.smack.StanzaListener, org.jivesoftware.smack.filter.StanzaFilter)' on a null object reference #23

Closed aldy-deptech closed 4 years ago

aldy-deptech commented 4 years ago

Describe the bug When connecting / login to cometchat

To Reproduce com.cometchat.pro.core.XMPPConnectionService.handlePresenceSubscriptions (XMPPConnectionService.java:405) com.cometchat.pro.core.XMPPConnectionService.access$1200 (XMPPConnectionService.java:100) com.cometchat.pro.core.XMPPConnectionService$8.run (XMPPConnectionService.java:332) java.lang.Thread.run (Thread.java:764)

Expected behavior cometchat will be connect / logged

Actual behavior force close / crash

Enviorment/Platfrom (please complete the following information):

Logs (Error Logs) com.cometchat.pro.core.XMPPConnectionService.handlePresenceSubscriptions (XMPPConnectionService.java:405) com.cometchat.pro.core.XMPPConnectionService.access$1200 (XMPPConnectionService.java:100) com.cometchat.pro.core.XMPPConnectionService$8.run (XMPPConnectionService.java:332) java.lang.Thread.run (Thread.java:764)

adityagokula2210 commented 4 years ago

hello @aldy-deptech we have released a new version of the CometChat Android SDK (version 2.0.2) a couple of days back. in this version, we have made a lot of optimizations for the init and login flow.. upgrading to this version should resolve this issue for you. If you still encounter this issue, please let us know and we will be happy to help you further Also, it seems that you are calling the CometChat.login() method every time the app starts.. ideally, you don't need to do that.. once the user logs in successfully into CometChat, the session for the user is maintained until the logout method is called. I suggest you use CometChat.getLoggedInUser() method to check if any user session is maintained in the SDK if this method returns null, you need to call the login method else it will return the details of the logged-in user upgrading to the latest version and making the above change to your login flow should fix this issue once and for all.. however, if you encounter this again, do let us know and we will be happy to help you out with this.

Thanks