Questions tagged [kodein]

For questions regarding the libraries of the Kodein Framework (a Kotlin/Multiplatform architecture component framework). Questions should specify which library is being asked about (DI, DB, Log, etc.) as well as the source-set in which the problem occurs (Android, Native, Common, etc.).

The Kodein Framework

The Kodein Framework provides several libraries that can be used independently or together. Each provides an opinionated architecture component to ease and accelerate Kotlin/Multiplatform applications.

Links:

Tag usage

When posting questions about Kodein libraries, please make sure to include:

  • The source-set where the issue arises (common, intermediate, platform).
  • The target system & compiler (Android, JVM, JS, Native).
  • Kotlin version.
89 questions
103
votes
4 answers

Why a viewmodel factory is needed in Android?

We have been discussing about this but we don't know the reason of creating a viewmodel factory to create a viewmodel instead of instantiate the viewmodel directly. What is the gain of creating a factory that just creates the viewmodel? I just put a…
Iban Arriola
  • 2,526
  • 9
  • 41
  • 88
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
4
votes
2 answers

Backend Internal error: Exception during psi2ir

I've been trying to use kodein in my android studio and I'm getting this issue The root cause org.jetbrains.kotlin.psi2ir.generators.ErrorExpressionException was thrown at:…
jp singh
  • 324
  • 2
  • 13
4
votes
1 answer

Android Instrumented tests with KodeIn

We have an Android app that is using compose for the view layer and we are using Kodein for all of our dependency injections. I have a BaseApplication class which is DIAware: class BaseApplication : Application(), DIAware { override val di: DI =…
Maurycy
  • 3,911
  • 8
  • 36
  • 44
4
votes
4 answers

How to pass argument to detail ViewModel via navArgs

I have a screen with a RecyclerView of podcasts, where when you click one, it takes you to a detail screen for that particular podcast. Using Kodein for ViewModel injection, how can I pass the id of the podcast that was clicked from the list…
Cameron
  • 1,281
  • 1
  • 19
  • 40
4
votes
1 answer

In Kodein dependency injection, how can you inject instances of Kodein itself into instances?

In Kodein, I have modules imported into a parent module, and sometimes the classes need an instance of Kodein so they can do injection themselves later. The problem is this code: val parentModule = Kodein { import(SomeService.module) } Where…
Jayson Minard
  • 84,842
  • 38
  • 184
  • 227
3
votes
2 answers

Kodein + Ktor = mutation attempt of frozen kotlin.collections.HashMap - why?

I have been struggling with this exception for couple of days recently. I have a kotlin multiplatform project with these dependencies: kotlin=1.5.10 kodein=7.6.0 ktor=1.6.0 (uses kotlin coroutines 1.5.0-native-mt internally) And I have been…
RadekJ
  • 2,835
  • 1
  • 19
  • 25
3
votes
2 answers

Android kodein difference between **bind() with** and **bind() from**

While studying about kodein i often see bind() with and bind() from. Can anyone please tell me what is the difference and why are we using it. Ex: bind() with provider { RandomDice(0, 5) } bind() with singleton {…
3
votes
0 answers

Unit Test with Kodein

I am trying to test my Retrofit class in unit tests and I am facing the problem of injecting dependencies into my test class. I have 3 classes: Service class : Retrofit interface Database class using Room (which requires an application…
mamenejr
  • 305
  • 9
  • 17
3
votes
1 answer

How i can make injection with Kodein?

I learn kodein lib for dependency injection just now. How i can take dependency value for variable? My application class below, there i bind context with kodein: class BaseApp : Application(), KodeinAware { override val kodein by Kodein.lazy { …
UjinUkr
  • 215
  • 5
  • 15
2
votes
1 answer

Kodein Injecting into WorkManager

I'm new to android development, i need to inject WorkManager for using kodein but i don't know where to start it this is how to inject activities class MyActivity : Activity(), KodeinAware { override val kodein by kodein() val ds: DataSource by…
ismacil jama
  • 69
  • 1
  • 7
2
votes
1 answer

Kodein vs Dagger - Can't Get Dagger Working w/ Multiple Modules

(x-post from /r/androiddev) I would just like to preface this by saying that this is not a "which is better" post; this is strictly a question about how I can build something using Dagger (and how I built it in Kodein to help illustrate the…
Eliezer
  • 7,209
  • 12
  • 56
  • 103
2
votes
1 answer

How to recover object with a factory binding with two arguments in kodein?

I called a ViewModel that gets three arguments in its constructor: class DetailViewModel( private val id: Long, private val tipo: String, private val msRepository: MSRepository) : ViewModel() { val establishmentProfessional by…
user67223
  • 33
  • 1
  • 6
2
votes
2 answers

Could not resolve org.kodein.di:kodein-di-framework-android

TL; DR Access to Kodein core packages at JCenter are unauthorized. Details We are using Kodein for dependency injection, but suddenly JCenter server is returning Unauthorized when Gradle tries to download any org.kodein.* artifact. * What went…
JP Ventura
  • 5,564
  • 6
  • 52
  • 69
2
votes
1 answer

When I use ViewModel.Factory, appear `Kodein No binding found for bind()` error

I reference to http://kodein.org/Kodein-DI/?6.1/android#view-model-factory use the kodein viewmodel, appeared the error. the part code bind() with singleton { KodeinViewModelFactory(instance()) } class…
Jie Xu
  • 99
  • 8
1
2 3 4 5 6