【问题标题】:Keep from R8 obfuscating: inner classes or interfaces, where outer class extends or implements避免 R8 混淆:内部类或接口,外部类扩展或实现
【发布时间】:2020-08-04 13:27:16
【问题描述】:

如果我想保留内部类,我使用-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)$*

【问题讨论】:

    标签: proguard obfuscation android-r8


    【解决方案1】:

    您应该能够使用以下条件保留规则:

    -if class com.example.** implements io.foo.bar.MyInterface
    -keep class com.example.<1>$*
    

    如果com.example 包中的类实现了io.foo.bar.MyInterface,则保留其所有内部类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 1970-01-01
      • 2014-05-10
      • 2012-06-13
      • 2020-10-05
      相关资源
      最近更新 更多