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.).

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

Kodein. Using property name (KProperty) in my factory

I want use information about property while creating instance. Example: @Test fun test() { val kodein = DI { bind<DataBasedPropertyName> { //What need ...
Темка тоже's user avatar
0 votes
1 answer
164 views

How to provide SqlDelight database in Compose Multiplatform using KodeIn

So far i've managed to declare expect class for DriverFactory expect class DriverFactory { fun createDriver(): SqlDriver } actual class DriverFactory(private val context: Context) { actual ...
alfietap's user avatar
  • 1,740
1 vote
1 answer
90 views

After adding these many dependencies project not responding

Build.gradle(Module:app) plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'kotlin-kapt' } android { namespace 'com.protocol.mvvmshoppinglist' compileSdk ...
DroidShakir's user avatar
0 votes
0 answers
23 views

Android Dynamic Feature Module with kodein frame work

What is the best way to use kodein with Android Dynamic feature module? Dyanamic module will be downloaded latter at some point. Is there any way to dynamically add module to kodein dependency. /* ...
Mayupal's user avatar
0 votes
1 answer
170 views

how to make many ViewModelFactory in kodein with kotlin

i use kodein principle in mvvm to set my ViewModelFactory with repositories class AddSpendApplication: Application(), KodeinAware { override val kodein: Kodein = Kodein.lazy { import(...
M.Shaker Nayyal's user avatar
0 votes
0 answers
370 views

How to use Kodein in KMM?

I have this initializer of Kodein in commonMain module: @ThreadLocal object CommonInjector { val kodeinContainer = DI.lazy { importAll(mainModule) } val mainModule = DI.Module(&...
Denis Steinman's user avatar
0 votes
1 answer
59 views

Kodeindb error, cant access my data object in my viewmodel

i have a data class for store in db. @kotlinx.serialization.Serializable data class SavedCalculation( override val id: String, val model1: Model1, val model2: Model2 ):org.kodein.db.model....
commandiron's user avatar
  • 1,135
5 votes
2 answers
2k views

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: org.jetbrains.kotlin....
jp singh's user avatar
  • 334
4 votes
1 answer
313 views

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 : ...
Maurycy's user avatar
  • 3,921
0 votes
1 answer
638 views

Cannot inject context into cookie manager with Kodein

I have the MVVM app build with KMM. ViewModel contains several use cases. Each use case calls methods of Repository and Repository calls NetworkService to execute the API call. Use cases, Repository ...
Sergei Mikhailovskii's user avatar
0 votes
1 answer
329 views

Cannot add latest Kodein version to KMM project

I faced the following problem: I need to add Kodein to the Android part of the KMM project. For this purpose, I added Kodein artefacts to the module's build.gradle file: plugins { id("com....
Sergei Mikhailovskii's user avatar
0 votes
0 answers
210 views

unable to find Kodein-db-0.8.1-beta-samplesources.jar in KMP application

I want to add Kodein to my application but I can't add it, it seems. This is the error I get: Could not find kodein-db-0.8.1-beta-samplessources.jar (org.kodein.db:kodein-db:0.8.1-beta). Searched in ...
James Black's user avatar
  • 41.6k
3 votes
2 answers
2k views

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....
RadekJ's user avatar
  • 2,903
0 votes
0 answers
374 views

How to prevent ViewModel recreation while using Kodein DI?

I tried to use Kodein DI library and used to to bind my Repo, NetworkService and viewModel like this bind<MovieNetworkService>() with singleton { instance<Retrofit>().create(...
Rahul Pawar's user avatar
1 vote
1 answer
784 views

Ktor / Kodein - How to write Integration Tests

Currently I write a small demo-app which uses Ktor as its Application Environment and Kodein as the Dependency Injection Framework. During the initialization of the Application I do import some ...
triplem's user avatar
  • 1,334
0 votes
1 answer
714 views

Fragment.viewLifecycleOwnerLiveData.observe doesn't call with kodein

i'm making an app and i want to separate my UI logic into multiple UI classes with BaseUi class being lifecycle aware. I'm using Kodein as my DI and i have an issue with fragment....
BorisTheCoder's user avatar
0 votes
1 answer
480 views

Kodein Scopes, Bind database service to an activity lifecycle

I've been trying to implement a custom scope in kodein for the past day and I am about to rip my hair off. My application is built on 2 activities, one activity for login, the other when the user is ...
Chnoou's user avatar
  • 23
0 votes
1 answer
449 views

Is Kodien verified at Compile Time?

I am starting a new KMM project and I want to integrate a DI system. I found that there are 2 options: Kodein and Koin. Sadly Koin is not verified at compile time like Dagger and I was wondering if ...
Zeyad Gasser's user avatar
  • 1,516
1 vote
1 answer
756 views

org.kodein.di.Kodein$NotFoundException: No binding found for bind<LLApi>() with ?<LoginFragment>().? { ? }

Iam doing a project with objectbox + retrofit + kodein. But I'm getting this error. org.kodein.di.Kodein$NotFoundException: No binding found for bind<LLApi>() with ?<LoginFragment>().? { ? ...
DSP's user avatar
  • 11
0 votes
1 answer
81 views

Kodein factory with interface. IDE suggestion produces incorect code

I have the following code in Kodein module bind<Manager>() with factory { strategy: OrderStrategyType -> val manager: Manager = when (strategy) { OrderStrategyType....
abi's user avatar
  • 99
1 vote
1 answer
1k views

How do i fix this Kodein error: Expression 'kodein' cannot be invoked as a function. The function 'invoke()' is not found

Here is the full error : e: C:\Users\HP\AndroidStudioProjects\MoneyManager\app\src\main\java\com\cruxrepublic\moneymanager\ui\auth\LoginActivity.kt: (22, 28): Expression 'kodein' cannot be invoked as ...
daniel_c's user avatar
-2 votes
1 answer
396 views

by instance() showing red line in android studio after updating android studio 4 in kotlin

by instance() showing red line after updating android studio 4 private val factory: SelectHospitalViewModelFactory by instance()
Sunil Kumar's user avatar
0 votes
1 answer
520 views

How to access an instance from one Kodein module in a different module?

When using Kodein, if I have 2 modules and module B needs to use an instance from module A, is the best practice to import module A into module B or is there a better way to do it? For example, I ...
frostyshadows's user avatar
0 votes
1 answer
607 views

Kodein - retrieve ViewModel fragment parent

I'm working on Android, but I guess the concept would be the same on every platforms. I have a fragment A hosting another fragment B using a NavHostFragment. I can retrieve the ViewModel from ...
user1750283's user avatar
0 votes
1 answer
290 views

Kodein returns a new instance instead of singleton

I'm new to Kodein and I've got this simple module : import com.myapp.MyApplication.Companion.INSTANCE import com.facebook.flipper.android.AndroidFlipperClient import com.facebook.flipper.core....
user1750283's user avatar
1 vote
3 answers
2k views

Kodein Framework - property delegate must have a provideDelegate(...) method

I'm trying to build an app with the following architecture: LoginActivity -> MainActivity -> everything else handled in fragments hosted by MainActivity. I'm also using the Kodein Framework for the ...
susosaurus's user avatar
4 votes
4 answers
4k views

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 ...
Cameron's user avatar
  • 1,341
1 vote
1 answer
1k views

Inject Saved State in ViewModelFactory with kodein

I develop app with MVVM pattern. I want save UI when user rotate screen. MyViewModel.kt class MyViewModel(val repository: SomeRepository, state : SavedStateHandle) : ViewModel(...
Павел Squad's user avatar
0 votes
1 answer
743 views

Kodein override binding for AndroidTest

I want to override a Kodein binding by a mock before testing my class. There is my Kodein init: val kodein = Kodein { bind<MyRepository>() with provider { MyRepository() } } Then my class ...
Darri's user avatar
  • 3
1 vote
1 answer
920 views

How to inject retrofit service with Firebase ID Token into kodein

I'm trying to inject a retrofit service into kodien. The API service uses Firebase Auth token for authenticating. So I've to pass the id token in request header as basic auth by the getting the token ...
varun's user avatar
  • 300
3 votes
2 answers
213 views

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<Dice>() with provider { ...
Android Rajaganapathi's user avatar
2 votes
1 answer
468 views

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 { ...
ismacil jama's user avatar
0 votes
1 answer
198 views

NullPointerException inside Kodein

I'm trying out Kotlin with Kodein and in my current project I'm getting a NPE inside Kodein and I'm don't know why. I have some data classes and matching repositories which deliver a list of them: ...
RoToRa's user avatar
  • 37.8k
0 votes
1 answer
1k views

org.kodein.di.Kodein$NotFoundException: 2 bindings found that match bind()

I have an interface WordsDataSource using which I have implemented two concrete classes namely WordsLocalDataSource that deals with local database and another WordsRemoteDataSource that deals with ...
Vaibhav Dhunde's user avatar
0 votes
1 answer
411 views

Kodein and activity context discuss

I have researched this example repo to understand how to implement Kodein in the Android app. But I was confused about the context questions in the activity case in the example. Here the code: ...
Serg Burlaka's user avatar
  • 2,411
1 vote
1 answer
4k views

Android Pass Context in object

I need to pass the Application Context to an object. This is to call a function to intercept in the okhttpClient, my connection service. I'am using an object class to build the connection to the ...
Hernâni Pereira's user avatar
3 votes
0 answers
973 views

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 ...
mamenejr's user avatar
  • 325
1 vote
0 answers
317 views

Kodein: Retrieve bindings in FirebaseMessagingService

I have a class that should process all notifications and therefore extends FirebaseMessagingService: class DefaultFCMHandler(): FirebaseMessagingService(), FCMHandler, KodeinAware { private val ...
F.M.F.'s user avatar
  • 1,971
0 votes
1 answer
391 views

How to insert and inject a arraylist into any service or activity class using kodein dependency injection?

Recently I have started to learn kodein dependency injection here I'm trying to load data into ArrayList and then inject that ArrayList into desired service or activity however I'm unable to do this ...
R.Coder's user avatar
  • 257
0 votes
0 answers
410 views

HTTP method annotation is required Retrofit2

I have an abstraction of usage of repository pattern and I'm not able to do a retrofit call. I'll go from Retrofit service to my use case. I've AuthenticationRetrofitService interface ...
StuartDTO's user avatar
  • 683
0 votes
1 answer
161 views

How to use Kodein with Conductor in Android?

I want to use both Conductor and Kodein in my application. The problem is that both the application context and the activity are null on the Controller setup and I can't access Kodein instance. class ...
Foad Saeidi Nik's user avatar
0 votes
2 answers
833 views

How to pass multiple parameter for Kodein Injected instances?

In Kodein, I have the below binding bind<AppDependent>() with multiton { title: String -> AppDependent(title, instance(), instance()) } I could get it created using private ...
Elye's user avatar
  • 55.2k
1 vote
1 answer
400 views

How to pass parameter for Kodein Injected instances?

In Kodein, when I have the below binding bind<AppDependent>() with singleton { AppDependent("abc", instance(), instance()) } I could get my appDependent using below private ...
Elye's user avatar
  • 55.2k
0 votes
2 answers
124 views

required: KodeinBinding<in ???, in ???, out TaskRepository>

In exploring Kodein, I'm following the example in https://proandroiddev.com/dependency-injection-with-kotlin-kodein-koin-3d783745e48d val diModel = Kodein.Module { bind<TasksRepository>() ...
Elye's user avatar
  • 55.2k
0 votes
0 answers
367 views

WorkManager and Kodein

I'm having troubles implementing android WorkManager with Kodein. I want to use the WorkManager to track background location updates and send post requests to my server periodically with the users new ...
mikle's user avatar
  • 21
1 vote
2 answers
3k views

Kotlin Kodein NotFoundException: No binding found for bind<String>() with ?<Fragment>()

I have a very simple set up. But I am unable to perform any networking within my the fragment that I am using Kodein in. The fragment inflates and handles all interaction but the networking layer ...
Sakiboy's user avatar
  • 7,292
0 votes
1 answer
2k views

Can I Inject activity's viewmodel and use It inside Dialog Fragment

I am trying to Inject activity's view model and I want use it inside Dialog Fragment, how to inject it with Kodein? and use the view model which I've inject before in other activity or fragments. I'...
Hyper Space's user avatar
1 vote
0 answers
894 views

Custom AndroidJUnitRunner not being used despite following examples

I am trying to use a custom AndroidJUnitRunner implementation with ActivityScenarios. The goal is to provide the unit tests an Application instance that is KodeinAware. However, despite following the ...
user11959096's user avatar
0 votes
1 answer
3k views

How to instance many parameters for Factory class with Kodein

I'm using Kodein as injecting dependency for my kotlin project. So I have a factory of my ViewModel like below class ReadViewModelFactory(private val readRepository: ReadRepositoryImpl, private val ...
Nanda Z's user avatar
  • 1,662
1 vote
1 answer
373 views

Can I use one Factory to bind viewmodel / repository calls with kodein

In this Factory I need to fetch my data from an api using Retrofit and store the cache with room, my Repository rules this app! I have repository suspended functions that take care of getting my data ...
user avatar