Closed dzmpr closed 3 months ago
Thanks for the PR!
The problem from the linked issue is caused by R8 performing class merging optimization (similar to what is described in this article). However, AddToEndSingleStrategy relies on commands to have different Classes. Therefore, we need to disable the optimization of classes that extend ViewCommand. This can achieved by using the following proguard rule:
-keep,allowobfuscation,allowshrinking class * extends moxy.viewstate.ViewCommand { *; }
I believe this rule is enough to fix the issue.
Regarding the issue, where R8 removes custom strategies. Moxy uses Class.newInstance() to reflectively create an instance of custom strategy given a strategy Class. However, in full mode, R8 removes the constructor, as stated in R8 FAQ:
The default constructor (\
()) is not implicitly kept when a class is kept.
So we need to write a rule to keeps this constructor:
-keepclassmembers class * extends moxy.viewstate.strategy.StateStrategy {
<init>();
}
@aasitnikov Can confirm that suggested rules are enough to fix problem. I updated PR.
Resolves #141