Skip to content

com.google.gson.JsonIOException: Abstract classes can't be instantiated! Register an InstanceCreator or a TypeAdapter for this type. #2379

@maheshordex

Description

@maheshordex

Gson version

'2.10.1'

Java / Android version

JDK 17
Android Android Studio Flamingo | 2022.2.1

Used tools

  • Maven; version:
  • Gradle; version:
  • ProGuard (attach the configuration file please); version:
  • ...

Description

When we convert json string to Model class it gives error related to adapter. I just updated android studio to latest version it works in older version.

Expected behavior

It should convert json string to Model class.

Actual behavior

It throws an error.

Reproduction steps

  1. ...
  2. ...

Exception stack trace

W  com.google.gson.JsonIOException: Abstract classes can't be instantiated! Register an InstanceCreator or a TypeAdapter for this type. Class name: com.xxx.xxx.data.pojo.other.GeneralResponse
2023-04-24 16:30:49.897 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.internal.ConstructorConstructor$3.construct(ConstructorConstructor.java:136)
2023-04-24 16:30:49.897 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$FieldReflectionAdapter.createAccumulator(ReflectiveTypeAdapterFactory.java:427)
2023-04-24 16:30:49.897 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:383)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.Gson.fromJson(Gson.java:1227)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.Gson.fromJson(Gson.java:1137)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.Gson.fromJson(Gson.java:1047)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.google.gson.Gson.fromJson(Gson.java:982)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.xxx.xxx.data.repository.BaseRepository.checkSuccess(BaseRepository.kt:8)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.xxx.xxx.data.repository.ApiRepository.login(ApiRepository.kt:51)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at com.xxx.xxx.data.repository.ApiRepository$login$1.invokeSuspend(ApiRepository.kt:0)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
2023-04-24 16:30:49.898 23084-23084 System.err              com.xxx.xxx                  W  	at android.os.Handler.handleCallback(Handler.java:938)
2023-04-24 16:30:49.899 23084-23084 System.err              com.xxx.xxx                  W  	at android.os.Handler.dispatchMessage(Handler.java:99)
2023-04-24 16:30:49.899 23084-23084 System.err              com.xxx.xxx                  W  	at android.os.Looper.loop(Looper.java:223)
2023-04-24 16:30:49.899 23084-23084 System.err              com.xxx.xxx                  W  	at android.app.ActivityThread.main(ActivityThread.java:7656)
2023-04-24 16:30:49.899 23084-23084 System.err              com.xxx.xxx                  W  	at java.lang.reflect.Method.invoke(Native Method)
2023-04-24 16:30:49.899 23084-23084 System.err              com.xxx.xxx                  W  	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
2023-04-24 16:30:49.899 23084-23084 System.err              com.xxx.xxx                  W  	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-infoproguard-r8Issues relating to the use of ProGuard and/or R8, such as problems due to obfuscation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions