In Clean Architecture, must Repository is Android or Kotlin module?

Viewed 676

In Clean Architecture, a Repository contains Remote (Retrofit) and Local (Room) data source. I see Remote is pure Kotlin module. However because Room need to access Android Context, thus Local is Android module.

So, must Repository is Android module because of Local module? And if yes, do you know any abstraction to avoid Context in Local module and make that module becomes pure Kotlin?

2 Answers

The distinction isn't between programming language. The deciding factor is whether it relies on any components from Android, such as Context, to operate.

I have a module written in kotlin that is a java-library. This library contains my "domain" logic and does not contain any Android components.

In your case, because you're using Room, yes this module will need to be a com.android.library module.

I don't think there is a way round this. You could split your module into two obviously: one for Retrofit (data-api) and one for Room (data-local)

Here's link It's good to see the open source on the link above.

Related