use asmack4.1 to login server,but throw StringIndexOutOfBoundsException

when I use asmack4.1 alpha2 jars to run on android 4.x os. and login server,it crash …

logs follow:

09-28 20:13:04.591: E/XmppTool(24813): java.lang.StringIndexOutOfBoundsException: length=68; index=68

09-28 20:13:04.591: I/System.out(24813): java.lang.StringIndexOutOfBoundsException: length=68; index=68

09-28 20:13:04.591: W/System.err(24813): org.jivesoftware.smack.SmackException$NotConnectedException

09-28 20:13:04.591: W/System.err(24813): at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:357)

09-28 20:13:04.591: W/System.err(24813): at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :353)

I have deal with this problem.

Android 4.x ruan network request will throw NetworkOnMainThreadException.

when i run the login action in the background thread. the problem “StringIndexOutOfBoundsException” dispeared.

Even if you have solved the issue, could you show the log output including all exceptions and their stacktraces?

09-28 20:13:04.591: E/XmppTool(24813): java.lang.StringIndexOutOfBoundsException: length=68; index=68

09-28 20:13:04.591: I/System.out(24813): java.lang.StringIndexOutOfBoundsException: length=68; index=68

09-28 20:13:04.591: W/System.err(24813): org.jivesoftware.smack.SmackException$NotConnectedException

09-28 20:13:04.591: W/System.err(24813): at org.jivesoftware.smack.tcp.XMPPTCPConnection.login(XMPPTCPConnection.java:357)

09-28 20:13:04.591: W/System.err(24813): at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :353)

09-28 20:13:04.591: W/System.err(24813): at com.ecan.mobilehealth.xmpp.IMHelper.login(IMHelper.java:33)

09-28 20:13:04.591: W/System.err(24813): at com.ecan.mobilehealth.ui.main.HomeFragment$5.onClick(HomeFragment.java:127)

09-28 20:13:04.591: W/System.err(24813): at android.view.View.performClick(View.java:4171)

09-28 20:13:04.591: W/System.err(24813): at android.view.View$PerformClick.run(View.java:17097)

09-28 20:13:04.591: W/System.err(24813): at android.os.Handler.handleCallback(Handler.java:615)

09-28 20:13:04.591: W/System.err(24813): at android.os.Handler.dispatchMessage(Handler.java:92)

09-28 20:13:04.591: W/System.err(24813): at android.os.Looper.loop(Looper.java:137)

09-28 20:13:04.591: W/System.err(24813): at android.app.ActivityThread.main(ActivityThread.java:4897)

09-28 20:13:04.591: W/System.err(24813): at java.lang.reflect.Method.invokeNative(Native Method)

09-28 20:13:04.591: W/System.err(24813): at java.lang.reflect.Method.invoke(Method.java:511)

09-28 20:13:04.591: W/System.err(24813): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808)

09-28 20:13:04.591: W/System.err(24813): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575)

09-28 20:13:04.591: W/System.err(24813): at dalvik.system.NativeStart.main(Native Method)

…,run on UI thread ,it thow the above log.

I don’t think so,The following is my error message:

java.lang.StringIndexOutOfBoundsException: length=156; index=156

at java.lang.AbstractStringBuilder.indexAndLength(AbstractStringBuilder.java:212)

at java.lang.AbstractStringBuilder.deleteCharAt0(AbstractStringBuilder.java:249)

at java.lang.StringBuilder.deleteCharAt(StringBuilder.java:359)

at org.jivesoftware.smack.SmackException$ConnectionException.from(SmackException.j ava:184)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectUsingConfiguration(XMPPTCPC onnection.java:595)

at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:858)

at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:313)

I went to see the source code, found to be due to the problems here(SmackException.java),:

public static ConnectionException from(List failedAddresses) {

StringBuilder sb = new StringBuilder("The following addresses failed: ");

for (HostAddress hostAddress : failedAddresses) {

sb.append(hostAddress.getErrorMessage());

sb.append(", ");

}

// Remove the last whitespace

** sb.deleteCharAt(sb.length());-------------------------------------------->probl em**

return new ConnectionException(sb.toString(), failedAddresses);

}

So I think that is the source of the problem

Right, a noob programming error done by me. Sigh.

Fixed in the latest 4.1.0-alpha3-SNAPSHOT.

I have two client, a mobile phone client (myself), a PC client (spark). My computer has logged in, when the mobile client login ,RosterListener - > pesenceChanged(mobile client—>smack api), can’t detect computer login state,why? can you help me?Old as can be。

4.1.0-alpha2-SNAPSHOT