NoClassDefFoundError: Resolución fallida de: Lokhttp3 / internal / Platform
Estoy usando la biblioteca Retrofit2
.
Ya he intentado actualizar la última versión: Retrofit2, Gson, Rxjava, OKHttp, HttpLoggingInterceptor … en el archivo build.gradle
- RxAndroid y Retrofit: No se puede crear el adaptador de llamada para io.reactivex.Observable <retrofit2.Response <okhttp3.ResponseBody >>
- Renovación de la referencia $ ref de objeto deserializante de JSON a su copia original
- Android - Retrofit 2 - Resultado del autenticador
- Convertidor personalizado para Retrofit 2
- Interfaz de deserialización de Gson para su implementación Class
build.grade
en la aplicación
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) // Default - Android Component testCompile 'junit:junit:4.12' compile 'com.android.support:design:24.2.1' compile 'com.android.support:appcompat-v7:24.2.1' // Retrofit2 + Gson compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.google.code.gson:gson:2.6.2' compile 'com.squareup.retrofit2:converter-gson:2.1.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0' compile 'com.squareup.okhttp3:logging-interceptor:3.3.0' compile 'com.squareup.okhttp3:okhttp:3.4.1' // RxJva compile 'io.reactivex:rxandroid:1.2.0' compile 'io.reactivex:rxjava:1.1.4' }
Pero tengo un error
> Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Platform; at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:112) at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:160) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at internal.NetworkModule$1.intercept(NetworkModule.java:150)
Debajo del código
Interceptor provideInterceptor(final Context context, final PreferenceStore preferenceStore) { Interceptor headerAuthorizationInterceptor = new Interceptor() { @Override public okhttp3.Response intercept(Interceptor.Chain chain) throws IOException { // Get Android ID String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); // Get Application Version String appVersion = ""; try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); appVersion = packageInfo.versionName; } catch (PackageManager.NameNotFoundException e) { Timber.e("Cannot get app version"); } /** * Add header with following attributes as agree with Web Server * - Token * - "Android" * - Release version * - Model * - App version * - Android ID */ String token = preferenceStore.getAuthToken(); Timber.i("X-Asukabu-Token: %s", token); // Add header to request Request request = chain.request(); if (token != null) request.headers().newBuilder() .add("X-Asukabu-Token", token) .add("X-Asukabu-Client-OS", "Android") .add("X-Asukabu-Client-OS-Version", Build.VERSION.RELEASE) .add("X-Asukabu-Client-Device", Build.MODEL) .add("X-Asukabu-Client-App-Version", appVersion) .add("X-Asukabu-Client-Device-ID", android_id) .add("Accept","*/*") .build(); else request.headers().newBuilder() .add("X-Asukabu-Client-OS", "Android") .add("X-Asukabu-Client-OS-Version", Build.VERSION.RELEASE) .add("X-Asukabu-Client-Device", Build.MODEL) .add("X-Asukabu-Client-App-Version", appVersion) .add("X-Asukabu-Client-Device-ID", android_id) .add("Accept","*/*") .build(); // ERROR IN THIS LINE : LINE 150 return chain.proceed(request); } }; return headerAuthorizationInterceptor; }
build.gradle
en Proyecto:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.2.0-rc2' // Dagger 2 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
La gente que sabe por qué tengo este error?
Por favor, dime cómo solucionarlo,
Gracias,
- Cómo saber cuándo finaliza una llamada de Retrofit
- Cómo resolver java.lang.AssertionError al crear OkHttpClient en mockito?
- Retrofit 2 no envía datos cuando ProGuard está habilitado
- ¿Cómo puedo devolver String o JSONObject de devolución de llamada asíncrona usando Retrofit?
- OkHttpClient lanza excepción después de actualizar a OkHttp3
- Retrofit, Generic Tipo de llamada
- Establecer url de base dinámica utilizando Retrofit 2.0 y Dagger 2
- ¿Cómo hacer una solicitud de POST utilizando retrofit 2?
Supongo que el problema está aquí:
compile 'com.squareup.okhttp3:logging-interceptor:3.3.0' compile 'com.squareup.okhttp3:okhttp:3.4.1'
Trate de hacer eso:
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' compile 'com.squareup.okhttp3:okhttp:3.4.1'
- Android vuelve a la primera actividad en el botón de clic
- DequeueBuffer: no se puede eliminar varios buffers sin establecer el contador de búfer