Какие версии okhttp и okhttp logging-interceptor следует использовать с Retrofit 2.1.0, чтобы избежать этой ошибки? - PullRequest
0 голосов
/ 24 мая 2018

Я получаю следующую ошибку при запуске модифицированного приложения:

E / AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher Process: fr.univ_lehavre.greah.naoderapp, PID: 20894 java.lang.NoSuchMethodError: Нет журнала виртуальных методов (Ljava / lang / String;) V в классе Lokhttp3 / internal / Platform;или его суперклассы (объявление okhttp3.internal.Platform) появляется в /data/app/fr.univ_lehavre.greah.naoderapp-2/split_lib_dependencies_apk.apk) по адресу okhttp3.logging.HttpLoggingInterceptor $ Logger $ 1.log (HttpceptInj: 108) по адресу okhttp3.logging.HttpLoggingInterceptor.intercept (HttpLoggingInterceptor.java:157) по адресу okhttp3.RealCall $ ApplicationInterceptorChain.proceed (RealCall.java:190) по адресу okhttp3.RealCall.getResponsehaj ().access $ 100 (RealCall.java:30) в okhttp3.RealCall $ AsyncCall.execute (RealCall.java:127) в okhttp3.internal.NamedRunnable.run (NamedRunnable.java:32) в java.util.concurrent.ThreadPounorkecutor(ThreadPoolExecutor.java:1133) в java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:607) в java.lang.Thread.run (Thread.java:761)

Это класс, в котором я создаю модифицированный объект:

public class RetrofitImpl {

private static Retrofit retrofit = null;
public static final String BASE_URL = "http://192.168.43.144:8080/";
//    public static final String BASE_URL = "http://10.0.2.2:8080/";

public static Retrofit getClient() {

    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())
            .client(client)
            .build();
    return retrofit;
}

}

Я не уверен, какие версии мне следует использовать.

Вот те, которые я сейчас использую:

implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.0.0-RC1'

Спасибо.

1 Ответ

0 голосов
/ 24 мая 2018

Попробуйте добавить эти версии.

 compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
 compile 'com.squareup.retrofit2:retrofit:2.3.0'
...