app: add proguard rules for retrofit with r8 in full mode
authorDa Risk <da_risk@geekorum.com>
Fri, 28 Apr 2023 10:54:19 -0400
changeset 1021 08837cef1aee
parent 1020 35d86e87cd75
child 1022 fcad2550e49e
app: add proguard rules for retrofit with r8 in full mode
app/proguard-rules.pro
--- a/app/proguard-rules.pro	Thu Apr 27 23:08:54 2023 -0400
+++ b/app/proguard-rules.pro	Fri Apr 28 10:54:19 2023 -0400
@@ -37,6 +37,23 @@
 -keepclassmembers,allowshrinking,allowobfuscation interface * {
     @retrofit2.http.* <methods>;
 }
+# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
+# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
+-if interface * { @retrofit2.http.* <methods>; }
+-keep,allowobfuscation interface <1>
+
+# Keep inherited services.
+-if interface * { @retrofit2.http.* <methods>; }
+-keep,allowobfuscation interface * extends <1>
+
+# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items).
+-keep,allowobfuscation,allowshrinking interface retrofit2.Call
+-keep,allowobfuscation,allowshrinking class retrofit2.Response
+
+# With R8 full mode generic signatures are stripped for classes that are not
+# kept. Suspend functions are wrapped in continuations where the type argument
+# is used.
+-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
 
 # Ignore annotation used for build tooling.
 -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement