Java.lang.NoClassDefFoundError: com.squareup.okhttp.MediaType

I get this error when changing my code from the default HTTPClient to OkHTTP . Searched over the Internet, but it is not allowed.

I tried the same with the OkHTTP library from here , as well as with the dependency but still the error is the same.

Please help me solve this problem.

Errors:

  01-01 22:03:18.038: E/AndroidRuntime(1460): java.lang.RuntimeException: An error occured while executing doInBackground() 01-01 22:03:18.038: E/AndroidRuntime(1460): at android.os.AsyncTask$3.done(AsyncTask.java:300) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.util.concurrent.FutureTask.setException(FutureTask.java:222) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.util.concurrent.FutureTask.run(FutureTask.java:242) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.lang.Thread.run(Thread.java:841) 01-01 22:03:18.038: E/AndroidRuntime(1460): Caused by: java.lang.NoClassDefFoundError: com.squareup.okhttp.MediaType 01-01 22:03:18.038: E/AndroidRuntime(1460): at com.kaverisoft.servicemanager.api.RemoteAPI.<clinit>(RemoteAPI.java:340) 01-01 22:03:18.038: E/AndroidRuntime(1460): at com.kaverisoft.servicemanager.BusinessCodeActivity$ActivationCodeConfirmation.doInBackground(BusinessCodeActivity.java:314) 01-01 22:03:18.038: E/AndroidRuntime(1460): at com.kaverisoft.servicemanager.BusinessCodeActivity$ActivationCodeConfirmation.doInBackground(BusinessCodeActivity.java:1) 01-01 22:03:18.038: E/AndroidRuntime(1460): at android.os.AsyncTask$2.call(AsyncTask.java:288) 01-01 22:03:18.038: E/AndroidRuntime(1460): at java.util.concurrent.FutureTask.run(FutureTask.java:237) 01-01 22:03:18.038: E/AndroidRuntime(1460): ... 3 more 
+2
source share
1 answer

I solved this by making a Multidex application by looking at this link on how to make a multidex application.

+1
source

Source: https://habr.com/ru/post/1238404/


All Articles