Implementing/learning/reading about r8/proguard. I...
# squarelibraries
c
Implementing/learning/reading about r8/proguard. I stumbled upon the PR from Zac Sweers to add default r8 rules to kotlin-reflect and I'm reasearching whether or not my deps that come from square require proguard rules. Is the gist of r8 that you won't have to add proguard rules to any deps unless they use reflection?
w
Many libraries, and I believe all square libraries, ship with R8 rules embedded, so you don’t need to add them manually
👍 1
Other than that mostly yes, you don’t need any R8 rules as long as R8 can infer the usage automatically, and the biggest issue usually is reflection
🙏 1
c
Thank you Łukasz
👍 1
w
For example, here’s what rules OkHttp ships https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro. As long as you’re using R8, they’re picked up automatically (documented in https://developer.android.com/studio/build/shrink-code under
library dependencies
)
c
Oof. Still looks like guava doesn't have any automatically.
z
Guava doesn't embed any rules in their jar, wish they would
most libraries on the square side ship with the minimum that they need, but not necessarily all the ones needed for them to be used. With Moshi-kotlin for instance, it only keeps what's needed for it to work but you still have to keep any reflectively serialized models like any other reflective serializer would
c
Thanks for clarifying. Starting to get the hang of how proguard/r8 works. I just ended up removing guava. Only use a smalllllll set of it's functionality.