google / gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Apache License 2.0
23.27k stars 4.27k forks source link

Caused by java.lang.VerifyError #2185

Closed GiaGioi closed 8 months ago

GiaGioi commented 2 years ago

Caused by java.lang.VerifyError: Verifier rejected class com.google.gson.stream.JsonReader: char com.google.gson.stream.JsonReader.readEscapeCharacter(): [0xFFFFFFFF] code did not end where expected (195 vs. 210) int com.google.gson.stream.JsonReader.doPeek(): [0xFFFFFFFF] code did not end where expected (138149 vs. 590200) com.google.gson.stream.JsonToken com.google.gson.stream.JsonReader.peek(): [0xFFFFFFFF] bad exception entry: startAddr=715124820 endAddr=715186598 (size=87) (declaration of 'com.google.gson.stream.JsonReader' appears in base.apk!classes2.dex) at com.google.gson.Gson.newJsonReader(Gson.java:728) at com.google.gson.Gson.fromJson(Gson.java:851) at com.google.gson.Gson.fromJson(Gson.java:801) at jp.softbank.mb.dtm.features.sb16home.CardHolder.getListCardCurrent(CardHolder.java:228)

I have encountered this error code recently and the json return verify error code i am not able to solve this hope anyone can help me.

Marcono1234 commented 2 years ago

Could you please provide more information?

(Also in general, please do not remove all the placeholder text from GitHub issue templates; it was explicitly asking for this information.)

GiaGioi commented 2 years ago

* Which Gson version are you using? I using Gson version: io.gsonfire:gson-fire:1.8.0 And use some exclude with other libraries like: com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.1, com.mapbox.mapboxsdk:mapbox-android-core:3.0.0, com.google.firebase:firebase-firestore:21.3.1

* On which platform does this occur? E.g. Android (if so, which version, does this only occur in release mode?), JDK It happens on Android, we're testing it on the unofficial store version and using JDK 8

* Which build tools (Gradle, Maven, ...) are you using? We are using gradle

Marcono1234 commented 2 years ago

I using Gson version: io.gsonfire:gson-fire:1.8.0

Ok, I assume that means you are using Gson 2.7 (see gson-fire pom.xml). Could you please try configuring your Gradle build script to use a newer Gson version (see documentation)?

It happens on Android, we're testing it on the unofficial store version and using JDK 8

Does this happen only with a release build, or also with debug builds (or also when running in the emulator)? In case this only happens with release builds, does this only occur on certain devices? And for which Android version does this occur?

Do we use proguard and we removed Gson from encryption

Just to be sure, could you test if it works if you completely disable ProGuard? In that case it might be related to the ProGuard configuration. Though it appears since Android Gradle plugin version 3.4.0 R8 is used by default (see documentation), so please check whether you are really using ProGuard, and not R8 (though ProGuard configuration also works for R8).

It looks like this is not a problem with Gson itself because to my knowledge Gson has produced valid JAR artifacts (otherwise this issue would have occurred much more often). Therefore it might be caused by how you build your app (or possibly a bug with the build tools); though I am not very familiar with Android.

Marcono1234 commented 8 months ago

I am going to close this because no answer has been provided. If you still experience this with the latest Gson version, feel free to comment here again with more details.