For injecting in none activity or fragment we use KoinComponent.
When i use this :
class MainClass(private val mContext:Context):KoinComponent {
private val mMainPresenter:MainPresenter by inject()
init {
startKoin {
androidContext(mContext)
modules(listOf(
apiModule,
repositoryModule,
dataBaseModule,
presenterModule,
viewModule
))
}
}
.
.
.
}
I faced with this error in run time:
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class de.netalic.mobiletoken.ui.MainFragment, unresolved supertypes: org.koin.core.KoinComponent
> Task :mobiletoken:bundleLibRuntimeDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
My dependencies are:
//Koin
implementation "org.koin:koin-android:2.0.1" //i implemented just this
implementation "org.koin:koin-core-ext:2.0.1"//I try to solve my problem with add these but these are not necessary
implementation "org.koin:koin-core:2.0.1"
implementation "org.koin:koin-android-scope:2.0.1"
implementation "org.koin:koin-android-ext:2.0.1"
I could not use KoinComponent finally then i use another way use blow :
` val mMainPresenter: MainPresenter by GlobalContext.get().koin.inject()`
@arnaudgiuliani
unresolved supertypes: org.koin.core.KoinComponent
more a project setup problem?
I think that i faced with this in one project.
Most helpful comment
I could not use
KoinComponentfinally then i use another way use blow :@arnaudgiuliani