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
5
votes
1 answer

koin default implementation without name reference

I have 2 Retrofit Clients one of them default and second one has different implementation like (base URL, interceptors etc... ) i need to inject default client without using name reference first client :- single { Retrofit.Builder() …
Eslam Hussein
  • 209
  • 2
  • 10
5
votes
2 answers

BeanInstanceCreationException: Can't create definition for Single

I'm trying to run instrumented tests under androidTest folder using Koin creator's example. Each test passes if I run them one by one. But when I run them all at once only the first passes. The rest is failed with: BeanInstanceCreationException:…
AlexKost
  • 2,792
  • 4
  • 22
  • 42
4
votes
1 answer

Injecting a CoroutineDispatcher using Koin

I was reading the data layer guide by Google and in the linked segment, they have the following snippet: class NewsRemoteDataSource( private val newsApi: NewsApi, private val ioDispatcher: CoroutineDispatcher ) { /** * Fetches the…
Stelios Papamichail
  • 955
  • 2
  • 19
  • 57
4
votes
1 answer

Android Koin injected viewmodel with multiple same class parameters fails

I'm following the docs as stated her https://insert-koin.io/docs/reference/koin-android/viewmodel/#viewmodel-and-injection-parameters The only difference is my viewmodel has 2 (besides Koin injected repos) parameters of the same class String. Lets…
sgtpotatoe
  • 340
  • 6
  • 17
4
votes
0 answers

Koin.error.NoBeanDefFoundException: No definition found for ViewModel class. Check your definitions

class LoginFragment : Fragment() { private lateinit var binding: FragmentLoginBinding private val viewModel : LoginViewModel by lazy {initViewModel()} override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, …
4
votes
0 answers

Android / Koin - Dynamically load data modules for features

I have many different feature modules and for each of them I've created a domain and data module. Here's my structure. feature-a feature_a_domain feature_a_data feature_a_ui feature-b feature_b_domain feature_b_data feature_b_ui Each feature is…
starlight
  • 41
  • 2
4
votes
1 answer

Room - Using @get:Query instead @Query

This project has MVVM, Room, Koin and Coroutines. Project code: @Dao interface MovieDao { @get:Query("select poster_path from Movie") val getImgPopularMovieList: LiveData> } What means "@get:Query" instead "@Query" and "val"…
4
votes
0 answers

Koin NoBeanDefFoundException

Long story short, I am facing strange app crashes with NoBeanDefFoundException, but it happens randomly. For some devices it works as expected and for others just crashes. I have a multi module project with lots of koin modules and it worked as…
Yamko
  • 535
  • 1
  • 3
  • 13
4
votes
1 answer

Method threw 'java.lang.StackOverflowError' exception in android when inject UseCase with koin

when I try to inject this line in my repositoryImpl in domain package: private val userUseCase: UserUseCase by inject() I got this error: java.lang.StackOverflowError: stack size 1040KB my package structure is: - data -> for retrofit, room, and…
Mehrdad Dolatkhah
  • 668
  • 2
  • 9
  • 28
4
votes
2 answers

Dynamic urls with Koin ans Retrofit

Using Retrofit for network calls and Koin for dependency injection in an Android app, how to support dynamic url change? (while using the app, users can switch to another server) EDIT: network module is declared like this: fun…
daneejela
  • 13,081
  • 7
  • 38
  • 50
4
votes
1 answer

Koin 2 problem with creating scope for feature in Android project

I try to create scope for a feature. I define a module like this. val appModule = module { scope(named("ARTIST_SCOPE")) { scoped { ArtistRepository(get()) } scoped { GetArtistsUseCase(get()) …
4
votes
1 answer

How to inject datarepository instance in Content provider using insert-koin

Facing Issues insert ContentProvider in AppModule. My app level Module is module { single { TinyDB.getInstance(get()) } single { DataRepository(get()) } viewModel { HomeViewModel(get()) } } I have no idea how to use…
4
votes
2 answers

How i change the retrofit URL at runtime

I need change the URL base in retrofit, i'm using koin to create a retrofit module on app startup and i want change this url in runtime. I already tried change the baseUrl("http://192.168.192.168/") to baseUrl("http://")and change the url on…
4
votes
1 answer

StandAloneContext Koin instance is null

As I added Koin to a project, I keep running into the following error. StandAloneContext Koin instance is null implementation 'org.koin:koin-android:1.0.2' Modules.kt val UIModule: Module = module { factory {…
murielg
  • 644
  • 2
  • 7
  • 15
4
votes
1 answer

Is it possible to build a project with Dynamic feature modules and Koin?

I have an app with different modules but the project is growing and we need to split the project in different Dynamic feature modules because the users (probably) would not need all the features. My problem is that Koin needs to be started from the…
Ch4vi
  • 391
  • 1
  • 5
  • 18