IncompatibleClassChangeError com.google.gson.annotations.SerializedName.value

We get an IncompatibleClassChangeError on a Samsung device when a user updates an application from the 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 the code is as follows:

 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 a JSON string, which is the server response.

+8
android gson
source share
2 answers

Sounds like a Samsung problem. Many people have the same problem not only with gson lib, but also with other libs. I think you canโ€™t do much, just wait until Samsung developers fix it .. This question has already been raised on the samsung developers forum http://developer.samsung.com/forum/board/thread/view.do?boardName=General&messageId = 280930

There are more bug reports here, and this only applies to Samsung devices. https://code.google.com/p/android/issues/detail?id=172339

Edit

Some of them also have this problem on devices other than Samsung, so this may not be entirely a Samsung error. This issue has already been assigned to the Google team. And as one member of the Google team said, if someone can share an error message with the team, they can fix it as soon as possible.

After reproducing the problem, go to the developerโ€™s settings, make sure that โ€œUSB debugging is enabled, then turn on the error report shortcut. Take the error report, press the power button and select theโ€œ Error report โ€option.

Note. Download the bug report to Google Drive and share the android-bugreport@google.com folder, and then share the link here .

+7
source share

Yes, this happens on most Samsung phones. I have the same problem too.

I got a solution to this.

At first, all telephone companies ignored comments (// or / * * /) in the .json file.

But now, Samsung developers are not ignoring this.

So the best solution is you should delete all comment lines (// or / * * /) in your .json file

0
source share

All Articles