You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Moshi expects JsonAdapters to have the ParameterizedType. But the R8 fullMode (which is enabled by default since AGP8) strips signatures from non-kept items. Therefore the check in parametersAreJsonAdapters (also in the Kotlin implementation) fails because of this assumption and you run into a IllegalArgumentException at runtime.
I was able to fix this by adding the following proguard rule: -keep,allowobfuscation,allowshrinking class com.squareup.moshi.JsonAdapter
Currently I just copy pasta this rule from other Android library projects, e.g. this PR which also contains a nice explanation: lysine-dev/retrofit#3579
I think this is also true for Moshi. But I am not really an expert on this topic.
Well, PR welcome but would need an explanation of the side effects. We're unlikely to accept a PR with broad proguard/R8 implications without that kind of detail.
R8 full mode can strip generic signatures from types unmatched by keep rules. Without JsonAdapter's signature, reflection exposes a raw delegate parameter, so Moshi's parameter validation fails and delegate binding cannot recover the type argument.
The embedded R8 rules now match JsonAdapter explicitly to retain its generic signature.
Activity
ZacSweers commentedon Apr 20, 2023
Wanna send a PR? I'd want to see a full description of the implications of that rule and its attributes, but open to it!
G00fY2 commentedon Apr 20, 2023
Currently I just copy pasta this rule from other Android library projects, e.g. this PR which also contains a nice explanation: lysine-dev/retrofit#3579
I think this is also true for Moshi. But I am not really an expert on this topic.
ZacSweers commentedon Apr 20, 2023
Well, PR welcome but would need an explanation of the side effects. We're unlikely to accept a PR with broad proguard/R8 implications without that kind of detail.
DarkAbhi commentedon Apr 27, 2023
G00fY2 commentedon Apr 27, 2023
@DarkAbhi Nope, your stacktrace seems not to be related to Moshi, since it would run into this error: https://github.com/square/moshi/blob/1.14.0/moshi/src/main/java/com/squareup/moshi/AdapterMethodsFactory.java#L226
DarkAbhi commentedon Apr 27, 2023
Right, thanks. I'm going to be running around a lot figuring this out..
DarkAbhi commentedon Apr 27, 2023
Fix 2.5.64 splash crash: disable R8 full mode (Moshi @FromJSON signat…
mvanhorn commentedon Oct 14, 2026
R8 full mode can strip generic signatures from types unmatched by keep rules. Without JsonAdapter's signature, reflection exposes a raw delegate parameter, so Moshi's parameter validation fails and delegate binding cannot recover the type argument.
The embedded R8 rules now match JsonAdapter explicitly to retain its generic signature.
#2139
Fix 2.5.64 splash crash: disable R8 full mode (Moshi @FromJSON signat…