1

我们单独使用 StethoInterceptor ,但它似乎在 hilt 重构设备存在于chrome://inspec 后不起作用,但网络选项卡为空

 @Singleton
        @Provides
        fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit = Retrofit.Builder()
                .baseUrl(RetrofitClientInstance.baseUrl)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create())
                .build()
    
        @Singleton
        @Provides
        fun provideOkHttpClient(): OkHttpClient =
                        OkHttpClient.Builder()
                        .protocols(listOf(Protocol.HTTP_1_1, Protocol.HTTP_2))
                        .addInterceptor(loggingInterceptor())
                        .connectTimeout(2, TimeUnit.MINUTES)
                        .writeTimeout(2, TimeUnit.MINUTES) // write timeout
                        .readTimeout(2, TimeUnit.MINUTES) // read timeout
                        .addInterceptor(TokenExpireInterceptor())
                        .addInterceptor(TokenAuthenticatorInterceptor())
                        .addInterceptor(RequestLoggingInterceptor())
                        .addNetworkInterceptor(StethoInterceptor())
                        .retryOnConnectionFailure(true)
                        .build()
4

0 回答 0