2016-09-17 10 views
32

私はRetrofit2ライブラリを使用しています。NoClassDefFoundError:解決策の失敗:Lokhttp3/internal/Platform

私はすでに最新バージョンに更新してみました:build.gradleファイルにRetrofit2、Gson、Rxjava、OKHttp、HttpLoggingInterceptor ...を

アプリケーション

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' 
} 

build.gradeしかし、私はエラー

> 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) 
を得ました

以下のコード

私はこのエラーを得た理由を知っている

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 
} 
} 

人物:プロジェクトにおける

build.gradle

は私が推測する、

答えて

87

をありがとう、問題はここにある、それを修正する方法を教えてください:

compile 'com.squareup.okhttp3:logging-interceptor:3.3.0' 
compile 'com.squareup.okhttp3:okhttp:3.4.1' 

はそれを作るために試してみてください。

compile 'com.squareup.okhttp3:logging-interceptor:3.4.1' 
compile 'com.squareup.okhttp3:okhttp:3.4.1' 
+5

だけ両方のライブラリに同じバージョンを追加します。 –

+0

私にとってはうまくいかない!私は 'compile 'を持っていませんcom.squareup.okhttp3:okhttp:3.4.1'' –

+5

別のライブラリの中にokhttpライブラリがあります。おそらく、改造 –

関連する問題