I am using Android R8 obfuscation in my Android library.
After including the AAR file in the application module of the library's client project, I am getting compile time errors for interfaces that are declared inside the class or another interface.
e.g. one of the public interfaces is MyPublicInterface:
interface InterfaceA {
fun a()
}
interface InterfaceB {
fun b()
}
class ClassA {
interface NestedInterfaceOfA {
fun nia()
}
}
interface MyPublicInterface : InterfaceA, InterfaceB, ClassA.NestedInterfaceOfA
The interface MyPublicInterface is used by the application module.
I am getting the below errors while compiling the application module:
"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"
I tried all the below rules:
-keepclasseswithmembers public interface * {
*;
}
-keepclasseswithmembernames public interface * {
*;
}
-keep public interface *$* {
*;
}
-keepclasseswithmembers public interface *$* {
*;
}
-keepclasseswithmembernames public interface *$* {
*;
}
-keepattributes InnerClasses, Signature
I tried by explicitly adding @Keep annotation in code and by explicitly adding the keep rule for a particular interface as well. But it didn't work.
Note: The entire code of the library is in Kotlin.
The above specified issue is resolved now. I used below solution for it:
Android studio version:
4.1.xAndroid tools version:
classpath 'com.android.tools.build:gradle:4.1.1'(Issue was occurring with version4.0.2)Gradle version:
6.5.1(Issue was occurring with version6.3)