Closed jd565 closed 3 years ago
Are you sure the stack trace really comes from a device running Gson 2.8.9? The stack trace looks a lot like Gson 2.8.7 or lower (before #1495 was integrated):
NoSuchFieldException
is thrown (most likely here)AssertionError
(here)The whole point of #1495 was to fix the situation you are seeing, where enum constant names were obfuscated, but have a @SerializedName
annotation and Gson should be able to handle them.
The line numbers in the provided stack trace also look a bit suspicious, maybe ProGuard is messing with the Gson library itself (though that would not directly explain this issue).
I will try again but the changes I made before were upgrading to 2.8.9 (from 2.8.8), and then we started seeing these crashes, and when I downgraded back to 2.8.8, it started working fine again.
Having had another look it looks like you are right:
Gson version
2.8.9
Java / Android version
Android compileSdk 31, target Java 1.8
Description
After upgrading from gson 2.8.8 to 2.8.9, we started seeing the following exception:
This happens when gson is creating the EnumTypeAdapter for the following class:
This enum is written in kotlin, and the class is not kept by proguard (The serialized name annotations should be telling gson how to parse this)
If I log out this info on a release build like follows:
I get: a - UNAVAILABLE - UNAVAILABLE b - DISABLED - DISABLED c - REQUESTED - REQUESTED d - PENDING - PENDING e - ENABLED - ENABLED
Expected behavior
Gson doesn't crash creating a type adapter
Actual behavior
Gson crashes creating a type adapter
Reproduction steps
Exception stack trace