@Keep 注释和保留规则不适用于通过启用 Android R8 混淆处理嵌套在类或其他接口中的接口

问题描述



我在我的 Android 库中使用 Android R8 混淆。 在库的客户端项目的应用程序模块中包含 AAR 文件后,我收到了在类或其他接口中声明的接口的编译时错误

例如公共接口之一是 MyPublicInterface:

interface InterfaceA {
    fun a()
}

interface InterfaceB {
    fun b()
}

class ClassA {
    interface nestedInterfaceOfA {
        fun nia()
    }
}

interface MyPublicInterface : InterfaceA,InterfaceB,ClassA.nestedInterfaceOfA

接口 MyPublicInterface 由应用程序模块使用。

我在编译应用程序模块时遇到以下错误

"Cannot access ClassA$nestedInterfaceOfA which is a supertype of MyPublicInterface. Please make sure you have the required dependencies in the classpath."
"unresolved supertypes ClassA$nestedInterfaceOfA"

我尝试了以下所有规则:

-keepclasseswithmembers public interface * {
*;
}
-keepclasseswithmembernames public interface * {
*;
}
-keep public interface *$* {
*;
}
-keepclasseswithmembers public interface *$* {
*;
}
-keepclasseswithmembernames public interface *$* {
*;
}
-keepattributes InnerClasses,Signature

我尝试通过在代码中显式添加 @Keep 注释并显式添加特定接口的保持规则。但是没有用。

注意:该库的整个代码都在 Kotlin 中。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)