arrow
arrow copied to clipboard
["Request"] Proguard docs
Code obfuscation and shrinking is intensely used in Android through ProGuard, and libraries use to include the proper ProGuard rules in their docs to make it easier for end users. We need someone to take a careful look at it and generate initial docs about it in the Quick Start section. Probably rules per module could work good.
This is interesting task, I would like to take it. What do we need as result? Keep all arrow
classes? What's the goal?
Figure out what classes cannot be stripped. There shouldn't be many, we don't use reflection.
Looks like there are two issues tracking this: https://github.com/arrow-kt/arrow/issues/500
This should be transparent given it also supports proguard rules, but keep in mind Proguard is not a thing anymore, it's R8.
This should be transparent given it also supports proguard rules, but keep in mind Proguard is not a thing anymore, it's R8.
True, but does R8 has its own rules or it uses Proguard ones?
@rcd27 R8 is compatible with Proguard so it uses the same rules 👍 see this for more info
Yep as I said it's transparent.
I've used standard https://android.googlesource.com/platform/sdk/+/master/files/proguard-android-optimize.txt to check how is it working. Build was successful, however app is broken (activity launches, but nothing happens). Writing here just to log progress. WIP
Check that you have the latest for direct and transitive dependencies!
Check that you have the latest for direct and transitive dependencies!
It is 10.2
in the project, if you are about arrow-kt
I'm using arrow version 0.9.0 and if I enable code obfuscation our app fails with this exception:
java.lang.NoSuchFieldException: No field completion in class Lk/v/i/a/a; (declaration of 'k.v.i.a.a' appears in .... base.apk) at java.lang.Class.getDeclaredField(Native Method) at arrow.typeclasses.ContinuationUtilsKt$completionField$2.invoke(:7) at arrow.typeclasses.ContinuationUtilsKt$completionField$2.invoke(Unknown Source:0) at kotlin.SynchronizedLazyImpl.getValue(:74) at arrow.typeclasses.ContinuationUtilsKt.getCompletionField(Unknown Source:7) at arrow.typeclasses.ContinuationUtilsKt.getCompletion(:10) at arrow.typeclasses.ContinuationUtilsKt.getCompletionField(:19)
Is this something that is fixed in a higher version? For now we don't use obfuscation but it would be nice to understand what is happening here.
Well, there are no R8/Proguard
rules yet as soon as issue is still open.
I'm using arrow version 0.9.0 and if I enable code obfuscation our app fails with this exception:
java.lang.NoSuchFieldException: No field completion in class Lk/v/i/a/a; (declaration of 'k.v.i.a.a' appears in .... base.apk) at java.lang.Class.getDeclaredField(Native Method) at arrow.typeclasses.ContinuationUtilsKt$completionField$2.invoke(:7) at arrow.typeclasses.ContinuationUtilsKt$completionField$2.invoke(Unknown Source:0) at kotlin.SynchronizedLazyImpl.getValue(:74) at arrow.typeclasses.ContinuationUtilsKt.getCompletionField(Unknown Source:7) at arrow.typeclasses.ContinuationUtilsKt.getCompletion(:10) at arrow.typeclasses.ContinuationUtilsKt.getCompletionField(:19)
Is this something that is fixed in a higher version? For now we don't use obfuscation but it would be nice to understand what is happening here.
Although @pakoito said there is no reflection, you can see in ContinuationUtils that there is at least that which causes this problem.
I was able to use R8 adding this rule to my proguard-rules.pro
to solve that specific issue:
-keepnames class kotlin.coroutines.jvm.internal.BaseContinuationImpl { kotlin.coroutines.Continuation completion; }
I guess this is still applicable to optics-reflect
, right @JorgeCastilloPrz?
That is the only library in Arrow that relies on reflection, so should it require an arrow.optics.*
configuration in proguard/R8.
I am unsure how this works these days.