I am making an android plugin for Unity, I need to integrate XMPP in Unity so first I am trying to create a connection of XMPP and send and receive a message. It's working fine in android, I am able to send and receive message But when I export .jar file and use in Unity so I got below error while I create connection
SmackInitialization: Could not determine Smack version java.lang.NullPointerException: lock == null at java.io.Reader.<init>(Reader.java:64) at java.io.InputStreamReader.<init>(InputStreamReader.java:122) at java.io.InputStreamReader.<init>(InputStreamReader.java:57) at org.jivesoftware.smack.SmackInitialization.<clinit>(SmackInitialization.java:61) at org.jivesoftware.smack.SmackConfiguration.getVersion(SmackConfiguration.java:96) at org.jivesoftware.smack.ConnectionConfiguration.<clinit>(ConnectionConfiguration.java:38) at com.arvaan.myplugins.ToastExample.connectXMPP(ToastExample.java:99) at com.unity3d.player.UnityPlayer.nativeRender(Native Method) at com.unity3d.player.UnityPlayer.a(Unknown Source) at com.unity3d.player.UnityPlayer$b$1.handleMessage(Unknown Source) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:234) at com.unity3d.player.UnityPlayer$b.run(Unknown Source)
I don't know what is an issue with Smack, I am new in Unity, I know how to create plugins and call method in Unity but don't know what's wrong over here.
Please check code :
public class ToastExample extends UnityPlayerActivity implements ConnectionListener, ChatManagerListener, RosterListener, PingFailedListener, StanzaListener, MessageListener, ChatMessageListener { private static final String TAG = ToastExample.class.getSimpleName(); private AbstractXMPPConnection mConnection = null; private ChatManager chatManager; private Chat chat; private Context context; private String userName = ""; private String passWord = ""; private String objectName = ""; private static ToastExample instance; public ToastExample() { this.instance = this; } public static ToastExample instance() { if (instance == null) { instance = new ToastExample(); } return instance; } public void setContext(Context context) { // This is also working fine Log.e(TAG, "setContext called"); this.context = context; } public void showMessage(String message) { // I can able to see toast Toast.makeText(this.context, message, Toast.LENGTH_SHORT).show(); } public void connectXMPP(String host, int port, String userName, String passWord) { Log.e(TAG, "_connectXMPP called"); XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder(); // Here i got error configBuilder.setUsernameAndPassword(userName, passWord); ............... ............... }
I am using below .Jar file in My Plugin and Unity
smack-core-4.1.4.jar smack-extensions-4.1.4.jar smack-im-4.1.4.jar smack-android-4.1.4.jar smack-android-extensions-4.1.4.jar smack-tcp-4.1.4.jar jxmpp-util-cache-0.4.2.jar jxmpp-core-0.4.2.jar jxmpp-jid-0.4.2.jar jxmpp-stringprep-libidn-0.4.2.jar minidns-core-0.2.0.jar**
Someone is also facing this issue but not found Check more
Please help me to sort out this issue, Thanks in Advance.!!!