Missing annotations for retrofit interace when using minifyEnabled

44 views Asked by At

When running a build without minifyEnabled (debug build) everything works just fine, but when building with minifyEnabled there is a runtime error when calling to Repository.getData.

The error is about missing annotations GET, PUT etc.

There are two retrofit2 interfaces that has one super interface:

interface Api1 : Api {
    @GET("/api/v1/data")
    override suspend fun loadData(): List<Entry>
}

interface Api2 : Api {
    @GET("/api/v1/data2")
    override suspend fun loadData(): List<Entry>
}

interface Api {
    suspend fun loadData(): List<Entry>
}

There is a dagger2 module, that provides retrofit for this interfaces:

    @Provides
    fun provideApi1(retrofit: Retrofit): Api1 = retrofit.create(Api1::class.java)

    @Provides
    fun provideApi2(retrofit: Retrofit): Api2 = retrofit.create(Api2::class.java)

Somewere in repository there is such a call:

class RepositoryImpl @Inject constructor(
    val api1: Api1,
    val api2: Api2
) : Repository {

    fun getData(param: Boolean) = flow {
        val api = if (param) api1 else api2
        emit(api.loadData())
    }

}

I've tried to add keepclasses for annotations and for the interfaces to proguard rules. It doesn't help.

0

There are 0 answers