如果要保留内部类,请使用-keep public class com.example.MyClass$MyInnerClass { *; }
(或-keep public class com.example.MyClass$* { *; }
保留任何多个内部类)。
问题:是否可以保留一个类的所有内部类,这些内部类通过扩展或实现来匹配签名?
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)$*
答案 0 :(得分:1)
您应该能够使用以下条件保留规则:
-if class com.example.** implements io.foo.bar.MyInterface
-keep class com.example.<1>$*
如果软件包com.example
中的类实现了io.foo.bar.MyInterface
,请保留其所有内部类。