Keep companion property from the child class but not from the parent

60 Views Asked by At

My situation is the following

I have class with a public companion object as it follows:

open class ParentClass {
...
   companion object {
      ...
      const val CONST_PROPERTY = "value"
   }
}

And other class ChildClassFromParentClass which inherits from ParentClass.

I use this property like this:

import package.ChildClassFromParentClass

class OtherClass {

...
   private fun doStuff() {
     val variable = ChildClassFromParentClass.CONST_PROPERTY
   }
...
}

It is possible to configure proguard-rules.pro to expose ChildClassFromParentClass.CONST_PROPERTY but obfuscate ParentClass.CONST_PROPERTY?

I've tried this, but it's not working

-keepclassmembers class package.ChildClassFromParentClass$** {
    public static ** Companion;
}
0

There are 0 best solutions below