diff --git a/viewmodel/build.gradle b/viewmodel/build.gradle index d664bd4..1602732 100644 --- a/viewmodel/build.gradle +++ b/viewmodel/build.gradle @@ -19,6 +19,7 @@ android { minSdk 14 targetSdk libs.versions.targetSdk.get().toInteger() testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + consumerProguardFiles 'proguard-rules.pro' } } diff --git a/viewmodel/proguard-rules.pro b/viewmodel/proguard-rules.pro new file mode 100644 index 0000000..adea95c --- /dev/null +++ b/viewmodel/proguard-rules.pro @@ -0,0 +1,11 @@ +# lich-viewmodel keys ViewModelStore entries by +# "lich:" + factory.javaClass.canonicalName, so every ViewModelFactory subclass +# must remain a distinct, stably-named class. Without this rule, R8 full mode +# horizontally merges the stateless companion factories into a single class, +# making all keys collide and returning the wrong ViewModel (ClassCastException). +# +# -keepnames (= -keep,allowshrinking) only pins the class *name*: it prevents +# renaming and class merging, keeps no members, and still allows unused +# factories to be removed. +# +-keepnames class * extends com.linecorp.lich.viewmodel.ViewModelFactory