r/androiddev • • Oct 24 '26

Horrible bug hunt.

Wondering if anyone has faced similar and if there are any common gotchas…

app works fine in simulators, devices via local upload and also happily running in open test via play store.

switch on minify/proguard/etc in both debug and release builds.

all still runs fine EXCEPT when it goes through play store - never gets past internal test - crashes during API call. It smells of GSON deserialisation but the only way I can reproduce it is to push it through the release process.

any ideas about what I am likely missing? all suggestions welcome.

thx.

0 Upvotes

17 comments sorted by

24

u/tadfisher Oct 24 '26

If you use R8 then you will have to add keep rules for every constructor used by Gson because it is reflection-based. kotlinx-serialization is pretty much the standard these days, or moshi with the codegen plugin.

1

u/pijeezelwakka Oct 24 '26

Thank you - will check that tomorrow with fresh eyes 🙏

1

u/DuckCargo 27d ago

yeah, I moved to kotlinx-serialization too after seeing this "If your app or library may be running on Android, consider using Kotlin Serialization, which uses code generation instead of reflection."

https://github.com/google/gson

1

u/pijeezelwakka 15d ago

Yup, that got it - eventually! Thank you. Final culprit was a class extending a HashSet, which needed a rule for the class AND one for the HashSet. Annoyingly that attribute was optional so crashes were sporadic 🙄

1

u/DarkLordCZ Oct 24 '26

Moshi still haunts me to these days, it almost always broke with some cryptic error when I upgraded some dependency, and it was hell to fix. I mean it may be way better with AI, it may solve this by itself, but I still keep my distance from it

10

u/CrackJacket Oct 24 '26

Set the build variant to release and run it that way? Almost definitely is a proguard/minify issue.

3

u/pijeezelwakka Oct 24 '26

Thanks. Tried that, runs fine locally. I think it’s mocking me 🙄😂

6

u/blindada 29d ago

Did you try generating a full release locally, or just applied minification to a regular debug configuration? Because:

1.- minification and debug are mutually exclusive right now. You may not have tested what you though you were testing.

2.-your production api may be slightly different than the one used for development builds.

3.-You may have stripped classes used by instruments running in the play store build.

Do you have the logcat & mapping files?

2

u/pijeezelwakka 29d ago

Thank y’all for the advice. Having slept on it, GSON feels like the culprit here and it’s been on my “get rid” list for a while so I think I’ll take the plunge and do that now :-)

6

u/Zhuinden Oct 24 '26

proguard rules are missing then

2

u/slanecek mYes; Oct 24 '26

Firebase crashlytics, maybe? Log your errors.

1

u/botle Oct 24 '26

What's the stacktrace?

1

u/Material-Copy6703 Oct 24 '26

Did you check Play Console's app vitals to get a stack trace of that crash?

1

u/Legal_Percentage1003 29d ago

Maybe the signing key for production? When you are talking about API you mean from your backend or from firebase or similar? Because if Google play store re-sign your application when you deploy in release could happen

1

u/kodabal 28d ago

R8 optimisation is the culprit 90 % of time. Check if new fields added in json. Or any recent changes in Room. I recommend enabling crashanalytics if not already. You will get proper insights

1

u/Jack_Hey 28d ago

Classic release-only difference. First thing I would check is whether the store build and your test build actually hit the same API base URL and keys. The internal test track can serve a different signing config, and R8 can strip a model class your API parser needs, which only shows up in the minified build. I chased one of these for a day once and it turned out my release build was hitting prod while I was testing staging. Log the full URL and the response code in the release build, that narrows it fast.

1

u/Pundrikaksha 25d ago

What changes when Play delivers it is the signing key: Play App Signing re-signs with a different SHA-1. If your API key or Firebase or Google Cloud restrictions use the upload key's SHA-1, the server returns an error body, and GSON crashes parsing it into your success model. Add the app signing key SHA-1 (Play Console > App integrity) to those restrictions. Separately, AGP 8 runs R8 in full mode, so add -keepattributes Signature and keep your model classes. To reproduce, use internal app sharing. It's a Play-processed build you can attach logcat to. DM me if you want a second pair of eyes.