0

First time using httpOk and retrofit. I'm using the code of another employee, but can't make it work, even after going into internet to check what is the potential error.

public static Retrofit getBsfBuilder() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();

    retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(client)
            .build();

     return retrofit;
}

With the declaration of the BASE_URL above, and the retrofit to null.

The error is

E/AndroidRuntime: FATAL EXCEPTION: main Process: , PID: 5305 java.lang.ExceptionInInitializerError

ace ofglad
  • 31
  • 7

1 Answers1

0

The issue was because I was using a version 19 android, with the latest version of okhttp, check How to fix Expected Android API level 21+ but was 19 in Android for more info

ace ofglad
  • 31
  • 7