airbnb / mavericks

Mavericks: Android on Autopilot
https://airbnb.io/mavericks/
Apache License 2.0
5.83k stars 500 forks source link

Proguard obfuscate MvRxViewModelFactory subclasses #185

Closed lirik16 closed 5 years ago

lirik16 commented 5 years ago

In the version 0.7.2, I've got a crash with enabled Proguard Caused by: java.lang.IllegalArgumentException: c takes dependencies other than initialState. It must have companion object implementing MvRxViewModelFactory with a create method returning a non-null ViewModel. It looks like the problem in the MvRxViewModelProvider.createViewModel because Proguard obfuscates Companion object. -keep class * implements com.airbnb.mvrx.MvRxViewModelFactory { *; } works for me to fix the problem.

gpeal commented 5 years ago

@BenSchwab FYI

chrisbanes commented 5 years ago

I've also just hit this. The following is a less 'keep everything' Proguard rule:

-keepnames class * implements com.airbnb.mvrx.MvRxViewModelFactory

tasomaniac commented 5 years ago

We also realized a R8 issue yesterday. App crashes on startup. Out stacktrace looks more like the one in the old issue. 🤔

https://github.com/airbnb/MvRx/issues/126

chrisbanes commented 5 years ago

@tasomaniac I'm using R8 too. Try these: https://github.com/chrisbanes/tivi/blob/master/app/proguard-rules.pro#L137