Category : okhttp

I am using okhttp3 version 4.9.3 , okhttp3 logging interceptor 4.9.3, and okio version 3.0.0. My code is something like the snippet below (I am using Android). But I always get this error: java.lang.NoClassDefFoundError: Failed resolution of: Lokio/Buffer. public void OkHttpTest(String token){ OkHttpClient client = new OkHttpClient().newBuilder() .build(); Request request = new Request.Builder() .url("https://cloud.seatable.io/api/v2.1/dtable/app-access-token/") .method("GET", ..

Read more

I’m looking for your help / ideas┬árelated to the problem below: What I want to achieve: route requests through mobile network on Android, using Retrofit2, OktHttp What I did: obtained the needed Network instance using ConnectivityManager set the socketFactory for OkHttpClient to use the one from the Network instance specified these permissions in AndroidManifest.xml.: <uses-permission ..

Read more

CheckServerTrusted is called when initialization with my server is made. However checkServerTrusted is also called when Google maps are initialized. Is it somehow possible to restrict checkServerTrusted just for initialization of connection to my server? So I want to checkServerTrusted to be called when initialization of connection with my server is made. //CustomOkHttpClient public static ..

Read more

here’s the code for the retrofit2 instance : import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor private const val BASE_URL = "http://10.0.2.2:5000/" class RetrofitInstance { companion object{ private val retrofitInstance by lazy { val interceptor = HttpLoggingInterceptor() interceptor.level = HttpLoggingInterceptor.Level.BODY val client = OkHttpClient.Builder() .addInterceptor(interceptor) .build() Retrofit.Builder() .client(client) .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build() } val retrofitService by ..

Read more

I am newer in android. My android app is crashing after get 404 or 500 errors Error message: "retrofit2.HttpException: HTTP 404 Not Found at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53)" The same message after receiving 500 error. I am using retrofit2 and okHttpClient. I have ApiModule class where are joining 2 interceptor: HttpLoggingInterceptor and my AuthErrorInterceptor where i check apiToken. ..

Read more

I have created an application that reads data from Rest api. I used a retrofit with GsonConverterFactory. And when the application requests a request to the server it works fine but out of 5 request 2 the request gives a timeout. Why is this happening because of Server or Because of Api or because of ..

Read more

I want to write a ResponseBody to external storage(Download folder). Until just a week ago, everything was working perfectly, then I needed to update the okhttp3 version and now when I run my application, one of these scenarios happened: This is my retrofit: HttpLoggingInterceptor logging = new HttpLoggingInterceptor(); logging.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder() .addInterceptor(logging) ..

Read more

I am getting StrictMode Policy Warning in Google Play Store Console.I updated all retrofit library to latest version but still i am getting this error. StrictMode: StrictMode policy violation: android.os.strictmode.UntaggedSocketViolation: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage if anyone have solution of this issue please comment here is App build.gradle dependecies dependencies ..

Read more