SmackInitialization:无法确定Smack版本 [英] SmackInitialization: Could not determine Smack version

查看:187
本文介绍了SmackInitialization:无法确定Smack版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Unity创建一个android插件,我需要将XMPP集成到Unity中,因此首先我要尝试创建XMPP的连接并发送和接收消息. 在android中工作正常,我能够发送和接收消息,但是当我导出 .jar 文件并在Unity中使用时,在创建连接时出现了以下错误

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)

我不知道Smack的问题是什么,我是Unity的新手,我知道如何在Unity中创建插件和调用方法,但是不知道这是怎么回事.

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.

请检查代码:

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);
    ...............
    ...............
}

我正在使用我的插件和Unity"中的 .Jar 文件

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.!!!

推荐答案

由于这里没有人回答,我经过4天的研究与开发后如何解决它:

Since nobody has answered here I how I solved it after 4 days R&D:

  1. 请提取所有Smack-core-4.1.1.jar文件类,并将其传递到您的应用内.
  2. 还有另外3个文件:version,smack-config.xml,jul.properties,请将此文件粘贴到应用程序内的Assests文件夹中.
  3. 在Smack软件包中有一个类:SmackInitialization.java,请替换下面的代码. 在此处编码
  4. 完成后,请制作.Jar文件并在Unity中使用.在此处检查
  1. Please exrect all classes of Smack-core-4.1.1.jar file and past inside your app.
  2. There is other 3 more file : version, smack-config.xml,jul.properties , Please paste this file in your Assests folder inside app.
  3. In Smack packages there is one class : SmackInitialization.java, please replace below code. Code Here
  4. Once you done please make .Jar file and use inside your Unity.Check Here

如果您遇到相同的错误,请随时告诉我,我们很乐意为您提供任何解决方案.

Let me know if you got same error i am happy to help you anytime for any solution.

谢谢

这篇关于SmackInitialization:无法确定Smack版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆