Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/params/BasicHttpParams;

Tags:

android

http

I have Upgraded the Android application from 26 to 28 SDK.

It works well in 23 - 27 version.

But the new version will crash in SDK 28.

this is the exception stack:

java.lang.RuntimeException: An error occurred while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:354)
    at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
    at java.util.concurrent.FutureTask.run(FutureTask.java:271)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at java.lang.Thread.run(Thread.java:764)
 Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/params/BasicHttpParams;
    at com.deepnet.andmob5.util.UtilsYang.getNewHttpClient(UtilsYang.java:163)
    at com.deepnet.andmob5.util.UtilsYang.makeRequest(UtilsYang.java:103)
    at com.deepnet.andmob5.util.UtilsYang.sendHTTPPost(UtilsYang.java:426)
    at com.deepnet.andmob5.threads.MyAsyncTask.doInBackground(MyAsyncTask.java:52)
    at com.deepnet.andmob5.threads.MyAsyncTask.doInBackground(MyAsyncTask.java:22)
    at android.os.AsyncTask$2.call(AsyncTask.java:333)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
    at java.lang.Thread.run(Thread.java:764) 
 Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.params.BasicHttpParams" on path: DexPathList[[zip file "/data/app/com.deepnet.andmob5-lZYwyb5I5Tn71C5uAAbAOA==/base.apk"],nativeLibraryDirectories=[/data/app/com.deepnet.andmob5-lZYwyb5I5Tn71C5uAAbAOA==/lib/x86, /data/app/com.deepnet.andmob5-lZYwyb5I5Tn71C5uAAbAOA==/base.apk!/lib/x86, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)

Please help me.

like image 575
Zilong Wang Avatar asked Feb 21 '19 12:02

Zilong Wang


1 Answers

If you are using the Apache HTTP client, add the following in AndroidManifest.xml: refer this

<uses-library android:name="org.apache.http.legacy" android:required="false"/>
like image 102
iDroid Avatar answered Nov 14 '22 23:11

iDroid