We are getting IncompatibleClassChangeError
in Samsung device when user update app from Play Store. Please check below log.
java.lang.IncompatibleClassChangeError: Couldn't find com.google.gson.annotations.SerializedName.value
at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:659)
at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:641)
at libcore.reflect.AnnotationAccess.getDeclaredAnnotation(AnnotationAccess.java:170)
at java.lang.reflect.Field.getAnnotation(Field.java:242)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldName(ReflectiveTypeAdapterFactory.java:71)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldName(ReflectiveTypeAdapterFactory.java:67)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83)
at com.google.gson.Gson.getAdapter(Gson.java:359)
at com.google.gson.Gson.fromJson(Gson.java:809)
at com.google.gson.Gson.fromJson(Gson.java:775)
at com.google.gson.Gson.fromJson(Gson.java:724)
at com.google.gson.Gson.fromJson(Gson.java:696)
at com.cubii.utils.SessionManager.getUserID(SessionManager.java:70)
at com.cubii.BluetoothLeService.broadcastUpdate(BluetoothLeService.java:188)
at com.cubii.BluetoothLeService.access$400(BluetoothLeService.java:47)
at com.cubii.BluetoothLeService$1.onCharacteristicChanged(BluetoothLeService.java:139)
at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:443)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)`enter code here`
at android.os.Binder.execTransact(Binder.java:446)
And code is as below:
public int getUserID(){
try {
String json = preferences.getString("User", "");
LoginResponse loginResponse = new Gson().fromJson(json, LoginResponse.class);//getting error from this line
Integer id = 0;
if (loginResponse != null) {
if (loginResponse.getId() != null) {
id = loginResponse.getId();
} else {
id = loginResponse.getUserId();
}
}
return (id == null) ? 0 : id;
}catch (Exception e){
Logger.dump(e);
}
return 0;
}
LoginResponse is my POJO class.
preferences.getString("User", "")
will return JSON String which is Server response.
Looks like a Samsung Issue .. Lot of people are having the same issue not only with gson lib but also with other libs as well .I think you can't do much about it ,only wait for Samsung developers to fix this.. Already this question is raised on samsung developer forum http://developer.samsung.com/forum/board/thread/view.do?boardName=General&messageId=280930
There are more reports of the problem here and it only affects samsung devices. https://code.google.com/p/android/issues/detail?id=172339
Edit
Some of them are also having this issue on devices other than Samsung so it may not be completly Samsungs fault. This issue is already assigned to the Google team .And as one of the Google team member mentioned if someone can share the bug report to the team they can fix this ASAP.
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Note: Please upload the bug report to google drive and share the folder to [email protected], then share the link here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With