I developed a modular android application, but i have a problem in making domain module pure kotlin. I mean, i want my domain module be a kotlin (or java) library, not an android library. everything is ok till i use hilt to inject my repository interface into my usecase. Here i face some error.because hilt is an android library and i shouldn't use it. But i need it. as you can see :
import com.example.domain_article.repository.ArticleRepository
import javax.inject.Inject
class GetArticleListLocalUseCase @Inject constructor(
private val articleRepository: ArticleRepository) {
operator fun invoke() = articleRepository.getArticleListLocal()
}
here we have @Inject which belongs to hilt (dagger) and if i remove hilt dependency from gradle of domain module i will get an error.
what should i do to make my domain pure kotlin and hilt?
CodePudding user response:
I faced this before,
You can import the following:
import javax.inject.Inject
This would give @inject
without adding dagger-hilt to your domain module.