0

So. i'm trying to learn Koin, and trying to build an OKHttpClient with Logging Interceptor. But, when i tested it, it seems like the Logging Interceptor doesn't get added.

 single {
    HttpLoggingInterceptor()
        .setLevel(
            if (BuildConfig.DEBUG) {
                HttpLoggingInterceptor.Level.HEADERS
            } else {
                HttpLoggingInterceptor.Level.NONE
            }
        )
 } withOptions {
    createdAtStart()
 }

 single {
    OkHttpClient.Builder()
        .addInterceptor(get<HttpLoggingInterceptor>())
        .build()
 } withOptions {
    createdAtStart()
 }


 single<Retrofit> {
    Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .client(get())
        .validateEagerly(true)
        .build()
 } withOptions {
    createdAtStart()
 }

I follow the same step as when i used it with Dagger Hilt. And with Koin, the interceptor doesn't get added. Did i miss something?

lelestacia
  • 201
  • 2
  • 9

0 Answers0