Koin: Doesn't work with viewmodels (at least) on KitKat

Created on 26 Mar 2019  路  3Comments  路  Source: InsertKoinIO/koin

The exception "java.lang.NoClassDefFoundError: ru.il_agent.easymusic.screens.main.viewmodel.MainActivityViewModel" at start of module loading.

I have declared the viewModel in the module and I'm starting koin in Application.onCreate. With API 28 and newer that works fine. But with API 19 - doesn't.

def koin_version = '1.0.2'
implementation "org.koin:koin-core:$koin_version"
implementation "org.koin:koin-androidx-scope:$koin_version"
implementation "org.koin:koin-androidx-viewmodel:$koin_version"

val appModule = module {
viewModel { MainActivityViewModel(get(), get()) }
...
}

class Application : Application() {
override fun onCreate() {
startKoin(this, listOf(appModule))
super.onCreate()
...
}

Most helpful comment

The reason was that MainActivityViewModel had the method clear() which was hiding implicitly ViewModel's method with the same name and that's problem for Dalvik.

All 3 comments

Has nobody faced with the similar problem ? Really ?

Found that on api 21 works fine. Is it right conclusion that min api for Koin is 21 ?

The reason was that MainActivityViewModel had the method clear() which was hiding implicitly ViewModel's method with the same name and that's problem for Dalvik.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leodeleon22 picture leodeleon22  路  4Comments

Jeevuz picture Jeevuz  路  4Comments

hkelidari picture hkelidari  路  3Comments

dakuenjery picture dakuenjery  路  4Comments

erikhuizinga picture erikhuizinga  路  3Comments