I am trying to remove logging using R8/Proguard, and I used
-assumenosideeffects class android.util.Log {
v(...);
d(...);
i(...);
w(...);
e(...);
}
which works fine. The issue arrised when trying to remove the custom logging in com.mypackage
:
-assumenosideeffects class com.mypackage.MyCustomLogger {
v(...);
d(...);
i(...);
w(...);
e(...);
}
I have a rule that keeps all the public methods of the public classes from com.mypackage
:
-keep, allowoptimization public class com.mypackage.** {
public *;
}
which I can't remove due to the scope of the project. This rule seemingly overrides the assumenosideeffects
rule, and here is my question: how do I specify an exception to this keep rule? I know about the -if
option but I haven't seen it anywhere used in the negative. I've tried writing -if class !com.mypackage.Logger
before the -keep
rule, but the build is taking a ridiculous amount of time and just never finishes.
CodePudding user response:
I've found the answer, I need to add my Logger class within the keep rule like so:
-keep, allowoptimization public class !com.mypackage.MyCustomLogger, com.mypackage.** {
public *;
}