gson: Verifier rejected class com.google.gson.Gson

Hi, I am developing Android app and I faced wired issue recently. My app worked smoothly before, then it broke down few days ago. When I run my app, I got this error. java.lang.VerifyError: Verifier rejected class com.google.gson.Gson due to bad method void com.google.gson.Gson.<clinit>() (declaration of 'com.google.gson.Gson' appears in /data/app/com.xxx.xx-1/base.apk)

I tried many ways, but I still did not fix this error. Could someone help me for this error?

Best Regards.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20

Most upvoted comments

Hi, I’m getting the same thing in Google’s Pre-Launch report. The strange thing is that I haven’t changed a thing regarding the JSON library from the previous version and that version passed Pre-Launch without any errors

Issue: java.lang.VerifyError: Verifier rejected class com.google.gson.Gson: void com.google.gson.Gson.<clinit>() failed to verify: void com.google.gson.Gson.<clinit>(): [0x5] register v0 has type Precise Reference: com.google.gson.Gson$1 but expected Reference: com.google.gson.reflect.TypeToken (declaration of 'com.google.gson.Gson' appears in /data/app/com.bluegate.app-TXgbYn54WvvOMWt27q0CxQ==/base.apk)

Occurs on Pixel w/Android 8.0 and Pixel 2 w/Android P Preview

For me it was a pre-launch update on Google Publish. Once I opted out for pre-signing, everything passed. Go to the settings under pre-launch reports, go down to “Pre-launch report version”, and select to opt-out so your app doesn’t get recompiled.

@RobMans426 My App module uses the GSON library extensively. I have tried your solution but now getting compilation issues with errors as below – error: package com.google.gson.annotations does not exist import com.google.gson.annotations.Expose; error: package com.google.gson.annotations does not exist import com.google.gson.annotations.SerializedName;

If I do not add below line in my app/build.gradle file, compilation is success. But when I upload my app to playstore, it gives me errors which I have mentioned in previous comment [These errors I am getting in latest release to my app, previously no errors].

configurations.all{ exclude group: ‘com.google.code.gson’, module: ‘gson’ }

Please help.

Hi, @Iavkush

This is not related with this gson library. This is related with other 3rd part libraries that you used in your app level gradle. Some libraries include gson inside. You need to exclude gson from other libraries.

Please add following code in the app level gradle.

configurations.all{ exclude group: 'com.google.code.gson', module: 'gson' }

Hope this will help you!