Skip to content

Commit ef1a26a

Browse files
authored
R8 full mode rule update (#658)
Update rule to avoid error when using R8 3.3.x with enabled full mode
1 parent 58ca1ce commit ef1a26a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mvrx/proguard-rules.pro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
public static *** initialState(...);
1616
}
1717

18+
# If a companion object of a class is implementing com.airbnb.mvrx.MavericksViewModelFactory it is used to
19+
# instatiate ViewModels.
20+
# This is done by looking up classes defined as subclasses of the ViewModel class itself that implement
21+
# com.airbnb.mvrx.MavericksViewModelFactory and thus we need to ensure that the companion objects definition
22+
# stays within the ViewModel class during Proguard/Dexguard/R8 optimization. Which was not the case anymore with
23+
# R8 3.3.x with enabeld full mode
24+
# We can however rename or even shrink away the ViewModel/Companion class if they are not used.
25+
# This ensures we keep the companion objectet implementing that interface
26+
-keep,allowshrinking,allowobfuscation class **$Companion implements com.airbnb.mvrx.MavericksViewModelFactory
27+
# This ensures we keep the class that conmtains the Companion object we kept one line up.
28+
-if class **$Companion implements com.airbnb.mvrx.MavericksViewModelFactory
29+
-keep,allowshrinking,allowobfuscation class <1>
30+
1831
# If a MvRxViewModelFactory is used without JvmStatic, keep create and initalState methods which
1932
# are accessed via reflection.
2033
-keepclassmembers class ** implements com.airbnb.mvrx.MavericksViewModelFactory {

0 commit comments

Comments
 (0)