2

I'm working with such tutorial. I added own modules and viemodel like in this tutorial, only changed implementations:

implementation "io.insert-koin:koin-core:3.0.2"
implementation "io.insert-koin:koin-android:3.0.2"

instead of:

implementation "org.koin:koin-android:2.0.1"
implementation 'org.koin:koin-androidx-viewmodel:2.0.1'
implementation 'org.koin:koin-androidx-scope:2.0.1'

Registered them in App class:

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        startKoin {
            androidLogger(Level.DEBUG)
            androidContext(this@App)
            modules(listOf(repositoryModule, viewModelModule, retrofitModule, apiModule))
        }
    }
}

but I get such error:

java.lang.IncompatibleClassChangeError: Found interface kotlin.time.TimeMark, but class was expected (declaration of 'kotlin.time.TimeMark' appears in /data/app/pkg-ptdpYgWwV-BVxpo5sVLPxg==/base.apk!classes15.dex)

it points on this line:

modules(listOf(repositoryModule, viewModelModule, retrofitModule, apiModule))

my modules are below:

val viewModelModule = module {
    viewModel {
        UserViewModel(get())
    }
}

val repositoryModule = module {
    single {
        UserRepository(get())
    }
}

val apiModule = module {
    fun provideUseApi(retrofit: Retrofit): GithubApi {
        return retrofit.create(GithubApi::class.java)
    }

    single { provideUseApi(get()) }
}

val retrofitModule = module {
    fun provideHttpClient(): OkHttpClient {
        val okHttpClientBuilder = OkHttpClient.Builder()

        return okHttpClientBuilder.build()
    }

    fun provideRetrofit(client: OkHttpClient): Retrofit {
        return Retrofit.Builder()
            .baseUrl("https://api.github.com/")
            .addConverterFactory(GsonConverterFactory.create())
            .client(client)
            .build()
    }

    single { provideHttpClient() }
    single { provideRetrofit(get()) }
}

but what is the problem with my TimeMark which I don't use.

Andrew
  • 1,947
  • 2
  • 23
  • 61

1 Answers1

2

I ran into the same error with Koin. It helped me to replace

startKoin {
        androidLogger(Level.DEBUG)
        androidContext(this@App)
        modules(listOf(repositoryModule, viewModelModule, retrofitModule, apiModule))
    }

to

startKoin {
        androidLogger(Level.ERROR)
        androidContext(this@App)
        modules(listOf(repositoryModule, viewModelModule, retrofitModule, apiModule))
    }

Apparently some kind of conflict with libraries.