远离 R8 混淆:内部 classes 或接口,其中外部 class 扩展或实现
Keep from R8 obfuscating: inner classes or interfaces, where outer class extends or implements
如果我想保留内部 class,我使用 -keep public class com.example.MyClass$MyInnerClass { *; }
(或 -keep public class com.example.MyClass$* { *; }
保留任何多个内部 classes)。
问题:是否有可能通过扩展或实现来保留匹配签名的class的所有内部classes?
interface MyInterface { fun foo() }
class Foo : MyInterface {
override fun foo() {}
class Inner // <- keep these with one rule for all `MyInterface` implementations
class Another // <- keep these with one rule for all `MyInterface` implementations
}
class Bar : MyInterface {
override fun foo() {}
class Third // <- keep these with one rule for all `MyInterface` implementations
class Fourth // <- keep these with one rule for all `MyInterface` implementations
}
类似于-keep public class (com.example.** implements io.foo.bar.MyInterface)$*
您应该能够使用以下条件保留规则:
-if class com.example.** implements io.foo.bar.MyInterface
-keep class com.example.<1>$*
如果包 com.example
中的 class 实现 io.foo.bar.MyInterface
保留其所有内部 classes.
如果我想保留内部 class,我使用 -keep public class com.example.MyClass$MyInnerClass { *; }
(或 -keep public class com.example.MyClass$* { *; }
保留任何多个内部 classes)。
问题:是否有可能通过扩展或实现来保留匹配签名的class的所有内部classes?
interface MyInterface { fun foo() }
class Foo : MyInterface {
override fun foo() {}
class Inner // <- keep these with one rule for all `MyInterface` implementations
class Another // <- keep these with one rule for all `MyInterface` implementations
}
class Bar : MyInterface {
override fun foo() {}
class Third // <- keep these with one rule for all `MyInterface` implementations
class Fourth // <- keep these with one rule for all `MyInterface` implementations
}
类似于-keep public class (com.example.** implements io.foo.bar.MyInterface)$*
您应该能够使用以下条件保留规则:
-if class com.example.** implements io.foo.bar.MyInterface
-keep class com.example.<1>$*
如果包 com.example
中的 class 实现 io.foo.bar.MyInterface
保留其所有内部 classes.