Вопрос

I am using Kryonet for an Android app, and works perfectly on all Android versions but the 3.0 version. I am getting the following exception:

E/AndroidRuntime(16861): FATAL EXCEPTION: Thread-30
E/AndroidRuntime(16861): com.esotericsoftware.kryo.KryoException: java.lang.StringIndexOutOfBoundsException: start=0 end=5 data.length=512 index=6 length=5
E/AndroidRuntime(16861): Serialization trace:
E/AndroidRuntime(16861): email (com.momasoft.sudokutournament.network.Network$Login)
E/AndroidRuntime(16861): at com.esotericsoftware.kryo.serializers.FieldSerializer.write(FieldSerializer.java:203)

Why does this happen only on Android 3.0? Is there a way to solve it?

Thank you!

Это было полезно?

Решение

I found a solution, debugging the Kryo library: I suggest to change the following code from kryo:

com.esotericsoftware.kryo.io.Output.java:307

/***Change this: ***/
value.getBytes(0, charCount, buffer, position);
position += charCount;

/***for this: ***/
byte[] valueB = value.getBytes();
for (int j = 0; j < valueB.length; j++) {
   this.writeByte(valueB[j]);
}

the getBytes(int start, int end, byte[] elem, int offset) is deprecated, and gives problems in android 3.0.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top