java.lang.VerifyError при использовании OkHttp

Я использую этот код в моем проекте Android Studio:

HttpUrl url = new HttpUrl.Builder().scheme("http").host("www.somesite.com")
                                    .addPathSegment("kontakt")
                                    .addQueryParameter("yit_contact[imie]", name)
                                    .addQueryParameter("yit_contact[email]", email)
                                    .addQueryParameter("yit_contact[telefon]", telephone)
                                    .addQueryParameter("yit_contact[wiadomosc]", message)
                                    .addQueryParameter("yit_bot", "")
                                    .addQueryParameter("_wp_http_referer", "/kontakt/").build();
Request request = new Request.Builder().url(url).build();
Response response = new OkHttpClient().newCall(request).execute();

и я получаю эту ошибку, когда я пытаюсь получить Response объект:

java.lang.RuntimeException: An error occured while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:299)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
        at java.util.concurrent.FutureTask.run(FutureTask.java:239)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
        at java.lang.Thread.run(Thread.java:856)
 Caused by: java.lang.VerifyError: com/squareup/okhttp/internal/http/HttpConnection$AbstractSource
        at com.squareup.okhttp.internal.http.HttpConnection.newFixedLengthSource(HttpConnection.java:246)
        at com.squareup.okhttp.internal.http.HttpTransport.getTransferStream(HttpTransport.java:125)
        at com.squareup.okhttp.internal.http.HttpTransport.openResponseBody(HttpTransport.java:110)
        at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:926)
        at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
        at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
        at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
        at com.squareup.okhttp.Call.getResponse(Call.java:274)
        at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
        at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
        at com.squareup.okhttp.Call.execute(Call.java:81)
        at com.example.tomek.myapplication.KontaktActivity$SendEmail.doInBackground(KontaktActivity.java:135)
        at com.example.tomek.myapplication.KontaktActivity$SendEmail.doInBackground(KontaktActivity.java:87)
        at android.os.AsyncTask$2.call(AsyncTask.java:287)
        at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:856)

Я добавил JAR-файлы в проект:

compile files('libs/okhttp-2.4.0.jar')
compile files('libs/okio-1.0.0.jar')

Помогите.

1 ответ

Решение

Попробуйте добавить Okio-1.4.0, что требуется для OkHttp 2.4.0.

<dependency>
  <groupId>com.squareup.okio</groupId>
  <artifactId>okio</artifactId>
  <version>1.4.0</version>
</dependency>
Другие вопросы по тегам