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

前端之家收集整理的这篇文章主要介绍了android – IncompatibleClassChangeError com.google.gson.annotations.SerializedName.value前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
用户从Play商店更新应用程序时,我们在Samsung设备中收到IncompatibleClassChangeError.请检查下面的日志.
  1. java.lang.IncompatibleClassChangeError: Couldn't find com.google.gson.annotations.SerializedName.value
  2. at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:659)
  3. at libcore.reflect.AnnotationAccess.toAnnotationInstance(AnnotationAccess.java:641)
  4. at libcore.reflect.AnnotationAccess.getDeclaredAnnotation(AnnotationAccess.java:170)
  5. at java.lang.reflect.Field.getAnnotation(Field.java:242)
  6. at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldName(ReflectiveTypeAdapterFactory.java:71)
  7. at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldName(ReflectiveTypeAdapterFactory.java:67)
  8. at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:142)
  9. at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:83)
  10. at com.google.gson.Gson.getAdapter(Gson.java:359)
  11. at com.google.gson.Gson.fromJson(Gson.java:809)
  12. at com.google.gson.Gson.fromJson(Gson.java:775)
  13. at com.google.gson.Gson.fromJson(Gson.java:724)
  14. at com.google.gson.Gson.fromJson(Gson.java:696)
  15. at com.cubii.utils.SessionManager.getUserID(SessionManager.java:70)
  16. at com.cubii.BluetoothLeService.broadcastUpdate(BluetoothLeService.java:188)
  17. at com.cubii.BluetoothLeService.access$400(BluetoothLeService.java:47)
  18. at com.cubii.BluetoothLeService$1.onCharacteristicChanged(BluetoothLeService.java:139)
  19. at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:443)
  20. at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)`enter code here`
  21. at android.os.Binder.execTransact(Binder.java:446)

代码如下:

  1. public int getUserID(){
  2. try {
  3. String json = preferences.getString("User","");
  4.  
  5. LoginResponse loginResponse = new Gson().fromJson(json,LoginResponse.class);//getting error from this line
  6.  
  7. Integer id = 0;
  8. if (loginResponse != null) {
  9. if (loginResponse.getId() != null) {
  10. id = loginResponse.getId();
  11. } else {
  12. id = loginResponse.getUserId();
  13. }
  14. }
  15.  
  16. return (id == null) ? 0 : id;
  17. }catch (Exception e){
  18. Logger.dump(e);
  19. }
  20. return 0;
  21. }

LoginResponse是我的POJO课程.

  1. preferences.getString("User","")

将返回JSON字符串,这是服务器响应.

解决方法

看起来像三星问题..很多人不仅与gson lib有同样的问题,而且还有其他库.我认为你不能做太多,只等三星开发人员解决这个问题.已经这个问题是在三星开发者论坛 http://developer.samsung.com/forum/board/thread/view.do?boardName=General&messageId=280930上提出的

这里有更多关于此问题的报告,它只影响三星设备.
https://code.google.com/p/android/issues/detail?id=172339

编辑

他们中的一些人也在三星以外的设备上遇到这个问题,所以它可能不完全是三星的故障.此问题已分配给Google小组.作为Google团队成员之一,如果有人可以向团队分享错误报告,他们可以尽快解决此问题.

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 android-bugreport@google.com,then share the link 07002.

猜你在找的Android相关文章