I use Android + Kotlin + Proguard
Code
inferface Authentication {
val authenticated: Boolean
val lastAuthentication: Instant
fun authenticate(force: Boolean = false): Flow<Event>
suspend fun revokeAccess()
}
And an implementation of that interface
internal sealed class AuthenticationInternal(
private val trustProvider: TrustProvider) : Authentication {
override val authenticated: Boolean
get() = trustProvider.authenticatedBefore()
override val lastAuthentication: Instant
get() = trustProvider.getLastAuthenticatedTime()
override fun authenticate() = flow {
trustProvider.checkIntegrity()
emitAll(internalAuthenticate())
}.flowOn(Dispatchers.Default)
override suspend fun revokeAccess() {
trustProvider.revokeAccess()
}
}
-> During Kotlin Annotation Processing this interface gets (as expected) a default implementation:
Kotlin generated code:
Class: Authentication$DefaultImpls.dex
-> Now my issue: Since this class is generated and not reachable from Kotlin code, how can I keep this class using progurard.
In my release build, this class is put out of the release dex and the application crashes with an RuntimeException.
Note: Adding this to the proguard mappings file: -keep class com.my.package.AuthenticationInternal$DefaultImpls { *; } will not work, since it is not reachable
How can I keep kapt-generated classes with proguard?