Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verifier rejected class com.google.gson.Gson #1353

Closed
RobMans426 opened this issue Jul 19, 2018 · 20 comments
Closed

Verifier rejected class com.google.gson.Gson #1353

RobMans426 opened this issue Jul 19, 2018 · 20 comments

Comments

@RobMans426
Copy link

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.

@lavkush-verma
Copy link

lavkush-verma commented Jul 25, 2018

I am also facing the same issue.
Play store sending prelaunch report with errors.
Issue: java.lang.NoSuchMethodError: No virtual method a(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object; in class Lcom/google/gson/d; or its super classes (declaration of 'com.google.gson.d' appears in /data/app/com.google.android.apps.mtaas.crawler-1/base.apk)

java.lang.IllegalAccessError: Illegal class access: <my_package>.Network.e' attempting to access 'com.google.gson.d' (declaration of '<my_package>.Network.e' appears in /data/app/<my_package>-1/base.apk)

Any quick work around for this issue.

@RobMans426
Copy link
Author

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!

@lavkush-verma
Copy link

@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.

@RobMans426
Copy link
Author

RobMans426 commented Jul 25, 2018

@lavkush-verma
Can you run your app in your device with release mode without any issues?

please exclude gson from all libraries.
And add gson module like this.
implementation 'com.google.code.gson:gson:2.8.5

@lavkush-verma
Copy link

lavkush-verma commented Jul 25, 2018 via email

@RobMans426
Copy link
Author

Could u copy your app level gradle file here?

@tomerpetel
Copy link

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

@lavkush-verma
Copy link

lavkush-verma commented Jul 26, 2018

@RobMans426
Dependencies are add in this way ...
With GSON version = 2.8.2 or 2.8.5 (same issues)

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':volley')
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
exclude group: 'com.android.support', module: 'support-annotations'
}

implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:$rootProject.constraintLayoutVersion"

implementation "com.google.code.gson:gson:$rootProject.gsonVersion"
implementation "com.google.firebase:firebase-core:$rootProject.firebaseCoreVersion"
implementation "com.google.firebase:firebase-messaging:$rootProject.firebaseMessagingVersion"

implementation "com.facebook.android:facebook-android-sdk:$rootProject.facebookSDKVersion"
implementation "com.squareup.okhttp3:okhttp:$rootProject.okhttpVersion"

implementation "com.github.bumptech.glide:glide:$rootProject.glideVersion"
implementation "com.github.chrisbanes:PhotoView:$rootProject.photoViewVersion"

implementation "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"
implementation "org.greenrobot:eventbus:$rootProject.eventBusVersion"

}

@nostel
Copy link

nostel commented Jul 27, 2018

I have the same problem with @tomerpetel .
Everything is fine until yesterday...
Do you have any idea about this problem?

@dixit712
Copy link

I have the same problem with @tomerpetel @nostel
Everything is fine until yesterday...
Do you have any idea about this problem?

Dependencies are added in this way ...

dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})

compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.github.badoualy:stepper-indicator:1.0.6'
compile 'com.google.android.gms:play-services-analytics:11.2.2'
compile 'com.google.android.gms:play-services-ads:11.2.2'
compile 'com.google.android.gms:play-services-location:11.2.2'
compile 'com.google.android.gms:play-services-gcm:11.2.2'
compile 'com.google.android.gms:play-services-auth:11.2.2'
compile 'com.facebook.android:audience-network-sdk:4.27.1'
compile 'com.github.nguyenhoanglam:ImagePicker:1.1.3'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.1.0'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.google.code.gson:gson:2.7'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.onesignal:OneSignal:3.6.2'
compile 'com.getkeepsafe.relinker:relinker:1.2.3'
compile 'com.android.support:multidex:1.0.1'
compile 'io.huq:sourcekit:1.1.19'
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'org.bytedeco:javacv:1.2'
compile 'org.bytedeco:javacpp:1.2.3'
testCompile 'junit:junit:4.12'
compile project(':colorselector')
compile files('libs/jar_sans.jar')

@nostel
Copy link

nostel commented Jul 28, 2018

Hi, guy. I'm sure this is a bug from Firebase Testlab. And I found the steps to reproduce it and a quick fix:

Steps to reproduce:

  • Create an empty android application
  • Add gson library dependency into app graddle: compile 'com.google.code.gson:gson:2.8.0'
  • In MainActivity file, add below lines to OnCreate function
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
    @OverRide
    public void run() {
    Gson gson = new Gson();
    }
    }, 5000);
  • Build the app and run a test on Firebase Testlab. Select device google pixel/ google pixel2. API version 26,27,28.
  • Wait for the report for Crashes

Here is a quick Cheat:

  • In MainActivity file, OnCreate function:

Replace:
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@OverRide
public void run() {
Gson gson = new Gson();
}
}, 5000);
With:
Gson gson = new Gson();

So basically, create a new Gson () instance immeadiately when app launch will prevent the crashes on Firebase test lab.

Hope that help you!

@ispam
Copy link

ispam commented Jul 29, 2018

I think this is related to this: googlesamples/google-services#358

@tomerpetel
Copy link

@ispam Why do you think it's related?
@nostel So do you think it's the pre-launch report bug? I was about to upload a version to production but I'm not sure now...

@ispam
Copy link

ispam commented Jul 29, 2018

@tomerpetel Because Im experiencing the same issue only in production. Tested on 4 Real devices from API 19-23. Plus im not rlly using GSON but i know some other libraries rely big on it.

@tomerpetel
Copy link

@ispam thanks for the answer. So if I'm understanding it right the fix was pushed to 100% of Android users (version v12.8.74) 3 days ago. So why I'm still seeing it in a report from 2 days ago?

@ispam
Copy link

ispam commented Jul 29, 2018

@tomerpetel Its been rolling out, but currently not update on my phones yet.

@tomerpetel
Copy link

@ispam Thanks mate 👍

@anudeepreddygopu
Copy link

Hey,

I am getting this issue all of a sudden. Is there anything which should be fixed. Everything seemed to work fine until today. I have rolled out a build which was not at all related to this, but it started crashing.

Fatal Exception: java.lang.VerifyError: Verifier rejected class com.google.gson.Gson: void com.google.gson.Gson.() failed to verify: void com.google.gson.Gson.(): [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.appname-aj6tBqViZ3DxYl_xUqAW_g==/base.apk:classes2.dex)
at com.google.gson.GsonBuilder.create(GsonBuilder.java:569)

How can I fix this? It seems like this error came only on the pixel device.

@tomerpetel
Copy link

@anudeepreddygopu see @ispam answer, fix has been released but it'll take time until propagated to all devices

@jasonandress
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants