![](/img/trans.png)
[英]Using GlidePalette :java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/OkHttpClient
[英]java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/okhttp/OkUrlFactory
我想設置超時超時
我添加了編譯'com.squareup.okhttp:okhttp:1.6.0'以在Retrofit中設置超時
應用程序崩潰並顯示錯誤
java.lang.NoClassDefFoundError:無法解決以下問題:Lcom / squareup / okhttp / OkUrlFactory
這是我的代碼
Gson localGson = new GsonBuilder().create();
final OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setReadTimeout(300, TimeUnit.SECONDS);
okHttpClient.setConnectTimeout(300, TimeUnit.SECONDS);
this.uploadService = ((IndentSyncService)new RestAdapter.Builder()
.setEndpoint(URL)
.setConverter(new GsonConverter(localGson))
.setClient(new OkClient(okHttpClient))//on this line app gets crash
.setRequestInterceptor(new RequestInterceptor()
{
public void intercept(RequestInterceptor.RequestFacade requestFacade)
{
//By adding header to the request will allow us to debug into .Net code in server
if (URL.contains("10.0.2.2")) {
requestFacade.addHeader("Host", "localhost");
}
}
})
.build().create(IndentSyncService.class));
我的搖籃
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.squareup.retrofit:retrofit:1.6.1'
compile 'com.squareup.okhttp:okhttp:1.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
testCompile 'junit:junit:4.12'
加
compile 'com.squareup.okhttp:okhttp-urlconnection:1.6.0'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.