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
52
votes
2 answers

java.lang.NoSuchMethodError: No virtual method elapsedNow()D in class Lkotlin/time/TimeMark

I have recently updated the version of Kotlin to 1.4.0-rc. Since then Koin is returning the run time error below: java.lang.NoSuchMethodError: No virtual method elapsedNow()D in class Lkotlin/time/TimeMark
Aydinozkan
  • 2,508
  • 2
  • 21
  • 26
45
votes
5 answers

Pass data back to previous fragment using Android Navigation

I've started using Android Architecture Components (Navigation and Safe Args, View Models) along with Koin library. Currently, I've got a problem with passing arguments between two fragments - I need to pass a string value from fragment A to…
43
votes
3 answers

Koin how to inject outside of Android activity / appcompatactivity

Koin is a new, lightweight library for DI and can be used in Android as well as in standalone kotlin apps. Usually you inject dependencies like this: class SplashScreenActivity : Activity() { val sampleClass : SampleClass by inject() …
33
votes
4 answers

How to Inject application context from 'app' module to 'network' module using Koin DI

I'm developing an application based on Koin DI (ver : 1.0.1) with 2 modules(:app and :network). I have a requirement in :network module to have "Context". Below is how I implemented: **Module**: val appModule = module { viewModel {…
user2064275
  • 332
  • 1
  • 3
  • 8
30
votes
2 answers

Why would I use Android Hilt (Dagger2) when Koin is available

I like to keep the number of third party libraries used in my Android Apps to an absolute minimum. I had started using Dagger2, then switched to Koin. Koin is such a great improvement on Dagger2. Koin has builtin ViewModel support and doesnt need…
Hector
  • 4,016
  • 21
  • 112
  • 211
26
votes
5 answers

java.lang.IllegalStateException: KoinApplication has not been started

I am learning kotlin using koin. While running the application in catlog I see the following message. java.lang.IllegalStateException: KoinApplication has not been started though I have used startKoin in MyApplication class MyApplication :…
anandyn02
  • 259
  • 1
  • 3
  • 6
26
votes
1 answer

Koin vs Kodein - Dependency Injection what you prefer? Kotlin

What dependency injection for Android with Kotlin do you prefer? I have started using Kodein but i don't want to lose my time if Koin it's better. I have read this presentation https://www.kotlindevelopment.com/koin-vs-kodein/ by Makery Kotlin…
SergioCT
  • 401
  • 1
  • 7
  • 12
22
votes
1 answer

JobScheduler JobService is started without Application

We converted our main Application class to Kotlin recently. Since then we are experiencing crashes, especially during the night (when our application was probably killed by the system), when our JobService is startet. We are accessing the…
marilion91
  • 2,094
  • 1
  • 19
  • 28
20
votes
5 answers

Hilt (Android): cannot find symbol return DaggerApp_HiltComponents_ApplicationC.builder()

I tried to replace Koin with Hilt (bad idea) for DI and now I'm stuck with this error: Hilt_App.java:21: error: cannot find symbol return DaggerApp_HiltComponents_ApplicationC.builder() ^ symbol: variable DaggerApp_HiltComponents_ApplicationC What…
iClaude
  • 707
  • 8
  • 14
19
votes
1 answer

How to add a Fragment's argument item to Koin dependency graph?

I have a ViewModel which has a dependency which should be taken from the Fragment's arguments. So its something like: class SomeViewModel(someValue: SomeValue) now the fragment recieves the SomeValue in its arguemnt like so: class SomeFragment :…
Archie G. Quiñones
  • 11,638
  • 18
  • 65
  • 107
18
votes
3 answers

Provide an Instance as its interface in Koin

Lets say I have two interfaces like: interface LetterClassifier interface NumberClassifier Then these interfaces would be applied to this class: class Classifier() : LetterClassifier, NumberClassifier Now, I want to provide these instances only as…
Archie G. Quiñones
  • 11,638
  • 18
  • 65
  • 107
17
votes
4 answers

How to share same instance of ViewModel between Activities using Koin DI?

I am using Koin library in Kotlin for DI Koin providing by viewmodel() for get instance of ViewModel by sharedViewModel() to get same instance in fragments. How can I get same instance of the ViewModel in activities ? I didn't find any way to…
Sahil Arora
  • 495
  • 1
  • 3
  • 11
17
votes
2 answers

Is it possible to create different instances of the same object and access them by passing parameters to get() function in Koin?

I am using Koin as a DI for my app. I created a module: object NetworkModule { fun get() = module { single { val authenticationInterceptor = Interceptor { chain -> // Request customization goes here …
Azizjon Kholmatov
  • 1,136
  • 1
  • 13
  • 26
16
votes
3 answers

How to share a viewmodel between two or more Jetpack composables inside a Compose NavGraph?

Consider this example. For authentication, we'll be using 2 screens - one screen to enter phone number and the other to enter OTP. Both these screens were made in Jetpack Compose and the for the NavGraph, we are using compose navigation. Also I have…
16
votes
5 answers

How to use Android DataStore with multi users or files

I want to store some preferences using DataStore. But the problem is that my application can have multiple users and therefor needs to store these preferences in separate files. I got a working example using only one user but I'm struggling to…
1
2 3
32 33