:thread: Koin Compiler I'm using Koin in a KMP pr...
# koin
p
🧵 Koin Compiler I'm using Koin in a KMP project (Android + iOS + Desktop), and I have KSP because I'm also using Room, but not Koin Annotations. I want to migrate to the new Koin Compiler. I followed the instructions, but I'm facing a compilation error when I try to build the project. Any guess?
Copy code
java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.fir.declarations.FirNamedFunction org.jetbrains.kotlin.fir.plugin.SimpleFunctionBuildingContextKt.createTopLevelFunction(org.jetbrains.kotlin.fir.extensions.FirExtension, org.jetbrains.kotlin.GeneratedDeclarationKey, org.jetbrains.kotlin.name.CallableId, org.jetbrains.kotlin.fir.types.ConeKotlinType, java.lang.String, kotlin.jvm.functions.Function1)'
	at org.koin.compiler.plugin.fir.KoinModuleFirGenerator.generateFunctions(KoinModuleFirGenerator.kt:888)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider.generateTopLevelFunctions(FirExtensionDeclarationsSymbolProvider.kt:140)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider.access$generateTopLevelFunctions(FirExtensionDeclarationsSymbolProvider.kt:29)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider$functionCache$1.invoke(FirExtensionDeclarationsSymbolProvider.kt:50)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider$functionCache$1.invoke(FirExtensionDeclarationsSymbolProvider.kt:49)
	at org.jetbrains.kotlin.fir.caches.FirThreadUnsafeCache.getValue(FirThreadUnsafeCachesFactory.kt:57)
	at org.jetbrains.kotlin.fir.extensions.FirExtensionDeclarationsSymbolProvider.getTopLevelCallableSymbolsTo(FirExtensionDeclarationsSymbolProvider.kt:278)
	at org.jetbrains.kotlin.fir.extensions.FirSwitchableExtensionDeclarationsSymbolProvider.getTopLevelCallableSymbolsTo(FirSwitchableExtensionDeclarationsSymbolProvider.kt:68)
If I remove the
alias(libs.plugins.koin.compiler.plugin)
, the project can build. But if will fails in runtime with:
Copy code
kotlin.NotImplementedError: Error while using 'startKoin<T>()'. The Koin Compiler plugin is missing. Please fix your setup to use 'io.insert-koin.compiler.plugin' Koin Gradle Plugin.
                                                    	at org.koin.plugin.module.dsl.CreateDSLKt.USE_KOIN_COMPILER_PLUGIN(CreateDSL.kt:7)
                                                    	at org.koin.plugin.module.dsl.ApplicationDSLExtKt.startKoin(ApplicationDSLExt.kt:33)
                                                    	at com.velantasistemas.money.di.InitializeKoinKt.initializeKoin(InitializeKoin.kt:45)
                                                    	at com.velantasistemas.money.android.MainApplication.onCreate(MainApplication.kt:17)
                                                    	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1396)
                                                    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8139)
t
It seems linked to incompatible version. Check you kotlin version, and if still not working, you may have another compiler that update under the hood the kotlin version. I have the same version incompatibility between Koin and Mokkery
p
I'm using:
Copy code
kotlin = "2.3.10"
kotlinx-coroutines = "1.10.2"
Which Kotlin version do you recommend?
j
2.3.20-beta2
p
I'm able to compile and run with the Kotlin version
2.3.20-Beta2
. Thanks! Now I've another error, but it's because the project was a little bit old and I need to upgrade other stuff. Thanks, folks!
a
2.3.20-beta1 is required. 2.3.20-beta2 is getting errors
p
I'm able to build with
2.3.20-beta2
but I'm facing some issues, like the error bellow. But I think it could be something wrong with my migration from KSP to Compiler in a KMP project.
Caused by: org.koin.core.error.NoDefinitionFoundException: No definition found for type 'com.x.y.features.cards.register.repository.CardsRepository' on scope '['_root_']'. Check your Modules configuration and add missing type and/or qualifier!
But I will give a try with
2.3.20-Beta1
!
The error above was in runtime. Is it should be in compile time, right? Because now I'm using the Koin Compiler. 🤔
a
yeah, but perhaps some generation are not done. You can activate logs to see how it works
p
It's working with
2.3.20-Beta1
!!!! For some reason, it is crashing (runtime) with a NoBeanDefFoundException in specific part of the project. I need to investigate it. I'll give a try in Kotzilla Platform to get more insights. 🙂 https://kotlinlang.slack.com/archives/C07AWM234RG/p1771425734194409
👍 1
The class
TagsRepository
was in
com.velantasistemas.money.features.database.repositories
, then I moved it to
com.velantasistemas.money.features.tags.repository
. So the app stops to crash in runtime because the DI module was in the same level (see the other screenshot). The module:
Copy code
@Module
@ComponentScan("com.velantasistemas.money.features.tags")
class TagsModule
But now my question is, why is it didn´t failed in compile time? 🤔
a
no compile time check yet
p
Do you have an ETA?
a
Working on it 💪 🔥 Should have somthing soon
koin parrot 2
187 Views