1

请你能帮忙分解一下你是如何让 asmack 在你的 android 中工作的。我无法让它为我的应用程序工作。我不断收到 java.lang.verifyError。

4

1 回答 1

3

确保在 libs 文件夹中包含最新版本的 asmack-android-17-0.8.3 asmack 库。添加这可能会删除java.lang.VerifyError.

我按照以下方式进行操作,效果很好。

public void login(View view)
{
     new Connection().execute("username", "password");
}

private class Connection extends AsyncTask<String, Void, Integer>
{
    private static final int CONNECTION_FAILURE = 0;
    private static final int LOGIN_FAILURE = 1;
    private static final int SUCCESS = 2;

    @Override
    protected Integer doInBackground(String... strings)
    {
        ConnectionConfiguration conConfig = new ConnectionConfiguration("192.168.1.100", 5222, "domain");
        connection = new XMPPConnection(conConfig);
  try
  {
      connection.connect();
      Log.i("AppName", "CONNECTED TO " + connection.getHost());
  }
  catch(Exception e)
  {
      Log.e("AppName", e.getMessage());
      return CONNECTION_FAILURE;
  }
  try
  {
      connection.login(strings[0], strings[1]);
      Log.i("AppName", "LOGGED IN AS " + connection.getUser());
      Presence presence = new Presence(Presence.Type.available);
      connection.sendPacket(presence);
  }
  catch(Exception e)
  {
      Log.e("AppName", e.getMessage());
      return LOGIN_FAILURE;
  }
  return SUCCESS;
    }
}
于 2013-06-16T10:07:01.623 回答