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

前端之家收集整理的这篇文章主要介绍了android – IncompatibleClassChangeError com.google.gson.annotations.SerializedName.value前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
用户从Play商店更新应用程序时,我们在Samsung设备中收到IncompatibleClassChangeError.请检查下面的日志.
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)

代码如下:

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是我的POJO课程.

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.

原文链接:https://www.f2er.com/android/318217.html

猜你在找的Android相关文章