Questions tagged [koin]

Koin is a Dependency Injection framework for Kotlin developers.

Koin is a pragmatic lightweight open-source dependency injection framework for Kotlin developers.

Links:

482 questions
3
votes
1 answer

SonarQube + Jacoco - Unable to read Koin module test coverage

I'm having some issues when trying to import Jacoco code coverage to sonar, this is happening to all Koin modules. Sonar version: 7.5.0.20127 Jacoco version: 0.8.2 Erro: ERROR: Cannot import coverage information for file…
xmarcusv
  • 63
  • 6
3
votes
2 answers

Is there any way to use Koin inject with generic?

I heve base class and I would like to use Koin injection on this base class like: abstract class BasePresenterFragment : BaseFragment() { lateinit var presenter: T by inject() // here is problem override fun onStart()…
Djek-Grif
  • 1,391
  • 18
  • 18
3
votes
3 answers

How to fix "No compatible definition found for type 'Context'" from Koin lib?

I just started using Koin lib in an android (to replace Dagger 2) project which was prepared for tests. I have an issue with the android app context in module: val M = module { val ctx = androidApplication() //here error } Koin is started in App…
LunaVulpo
  • 3,043
  • 5
  • 30
  • 58
2
votes
0 answers

"KoinApplication has not been started" while running KMM app on iOS, works in android

I have been stuck on this issue for 2 days and I am on the verge of breaking my computer. I am creating a Rick And Morty app using KMM, GraphQL and SQLDelight and all the dependency injection is done through Koin. The thing is, everything works…
Subfly
  • 492
  • 2
  • 13
2
votes
1 answer

Koin, can't find a way to use lazyModule in my app

I've seen in the official Koin's doc that is possible to declare a module as lazy to avoid to be pre-allocated on app startup, but I'can't find a way to make it work. In my gradle config file I have: api…
2
votes
0 answers

Instance creation error : could not create instance for 'AppDatabase. Cannot find implementation for AppDatabase. AppDatabase_Impl does not exist

I'm having an issue related to the use of Koin DI together with Room DB. I created all the needed components for Room as follows: @Dao interface CharacterDAO { @Query("SELECT * FROM character") suspend fun getAll(): List
Santo
  • 61
  • 4
2
votes
1 answer

Found interface kotlin.time.TimeMark error with Koin usage

I'm working with such tutorial. I added own modules and viemodel like in this tutorial, only changed implementations: implementation "io.insert-koin:koin-core:3.0.2" implementation "io.insert-koin:koin-android:3.0.2" instead of: implementation…
Andrew
  • 1,947
  • 2
  • 23
  • 61
2
votes
1 answer

Koin Android-KMM: I have nested scopes but injection is not working

I am getting this error. I am using Koin for dependency injection. I want my appointment repository to be alive as UserInfoContainer scope is alive. No definition found for class:'com.flow.domain.repository.AppointmentsRepository'. Check your…
2
votes
1 answer

Get all instances of an interface with Dagger Hilt

I'm migrating DI from Koin to Dagger Hilt. I have a custom interface with many implementations, and I want to inject all the instances in a useCase as a list. For example: @Singleton class MyUseCaseImpl @Inject constructor( private val…
ZookKep
  • 481
  • 5
  • 13
2
votes
2 answers

ViewModelScope might get canceled while inserting entries into a Room database

I'm building a score tracking app and I have a screen where you can add new players into a game. It's a simple screen that lets the user specify the player's name and color. This screen has its own ViewModel, which I inject into the screen's…
2
votes
2 answers

Gradle problems of adding koin test dependencies

I'm a beginner with gradle and would like to use koin in my Kotlin project. However, I get the following error Execution failed for task ':compileTestKotlin'. > Error while evaluating property 'filteredArgumentsMap' of task ':compileTestKotlin' >…
oberprah
  • 157
  • 1
  • 8
2
votes
1 answer

Injecting SavedStateHandle on old Koin library versions (example: 2.2.3)

I am working on a project that uses Koin in version 2.2.3 where I cannot upgrade it. I would like to know if it is possible to inject SavedStateHandle on ViewModels (mainly on shared ones) using that version somehow.
Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61
2
votes
1 answer

Ktor with Koin DI can't inject, missing clazz

I am setting up Koin DI on Ktor in this way: https://insert-koin.io/docs/reference/koin-ktor/ktor/ But I am getting an error: No value passed for parameter 'clazz' My implementation looks like this: import io.ktor.application.* import…
FailedUnitTest
  • 1,637
  • 3
  • 20
  • 43
2
votes
2 answers

How to implement Koin dependency injection in Room MVVM Architecture

I'm following this documentation to implement koin dependency injection but it couldn't help me. I'm stuck in Modules.kt file I don't know how to pass DAO interface of Database to Repository constructor in module of…
Yaqoob Bhatti
  • 1,271
  • 3
  • 14
  • 30
2
votes
0 answers

Getting empty savedStateHandle in jetpack compose when I am using koin

I have this view model which is throwing error because SavedStateHandle is empty. class DetailViewModel( savedStateHandle: SavedStateHandle, private val repository: Repository ) : ViewModel() { private val id: String =…
Vivart
  • 14,900
  • 6
  • 36
  • 74