romaint
03/26/2026, 2:25 PMMissing dependency error on some specific dependencies.
It builds and runs fine if i disable the compile safety of the plugin, but actually i want to keep it as it is the main reason why i want to use the compiler plugin.
I have those classes :
interface CrashLogger {
fun logException(exception: Throwable)
}
class FirebaseCrashLogger(private val firebaseInstance: FirebaseCrashlytics) : CrashLogger {
override fun logException(exception: Throwable) { ... }
}
And this in a koin module :
single { FirebaseCrashlytics.getInstance() }
single<FirebaseCrashLogger>() bind CrashLogger::class
For what i understand, single {...} is in org.koin.core.module package, while single<T>() is in org.koin.plugin.module.dsl package, from the compiler plugin itself.
The two seem incompatible because it is where the build gives me this error :
e: [Koin] Missing dependency: com.google.firebase.crashlytics.FirebaseCrashlytics
required by: dsl:com.myapp.crashlogger.FirebaseCrashLogger (parameter ‘firebaseInstance’)
in module: DSL graphI didn’t find a way to put the
FirebaseCrashlytics.getInstance() in a org.koin.plugin.module.dsl.single as it does not accept a builder block.
I did try this, as create(function: () -> T): T is from org.koin.plugin.module.dsl :
single<FirebaseCrashlytics> { create(FirebaseCrashlytics::getInstance) }
But that doesn’t work either.
However it works if i use singleOf(::FirebaseCrashLogger) bind CrashLogger::class
Therefore, the migration to Koin 4.2.0 cannot be fully done and I don’t really know if the compiler performs security checks in these cases.romaint
03/26/2026, 3:47 PMprivate fun getFirebaseInstance() = FirebaseCrashlytics.getInstance()
module {
single { create(::getFirebaseInstance) }
singleFirebaseCrashLogger() bind CrashLogger::class
}