问题
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/DefaultHttpClient
I am not able to resolve below error :
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/DefaultHttpClient; at com.medicend.jykra.medicend.Async.Parser.LoginParser.hitWS(LoginParser.java:68) at com.medicend.jykra.medicend.Async.Parser.LoginParser.postData(LoginParser.java:50) at com.medicend.jykra.medicend.Activity.SignInActivity$LoginAsync.doInBackground(SignInActivity.java:91) at com.medicend.jykra.medicend.Activity.SignInActivity$LoginAsync.doInBackground(SignInActivity.java:73) 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.impl.client.DefaultHttpClient" on path: DexPathList[[zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/base.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_resources_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/lib/x86, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass(ClassLoader.java:379) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.medicend.jykra.medicend.Async.Parser.LoginParser.hitWS(LoginParser.java:68) at com.medicend.jykra.medicend.Async.Parser.LoginParser.postData(LoginParser.java:50) at com.medicend.jykra.medicend.Activity.SignInActivity$LoginAsync.doInBackground(SignInActivity.java:91) at com.medicend.jykra.medicend.Activity.SignInActivity$LoginAsync.doInBackground(SignInActivity.java:73) 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) Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_resources_apk.apk at dalvik.system.DexFile.openDexFileNative(Native Method) at dalvik.system.DexFile.openDexFile(DexFile.java:354) at dalvik.system.DexFile.(DexFile.java:101) at dalvik.system.DexFile.(DexFile.java:75) at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394) at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354) at dalvik.system.DexPathList.(DexPathList.java:164) at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:74) at dalvik.system.BaseDexClassLoader.(BaseDexClassLoader.java:65) at dalvik.system.PathClassLoader.(PathClassLoader.java:64) at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73) E/AndroidRuntime: at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88) at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74) at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40) at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727) at android.app.LoadedApk.getClassLoader(LoadedApk.java:810) at android.app.LoadedApk.getResources(LoadedApk.java:1032) at android.app.ContextImpl.createAppContext(ContextImpl.java:2345) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749) at android.app.ActivityThread.access$1100(ActivityThread.java:199) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
回答1:
Add the following to your manifest file under 'application':
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p
回答2:
You are getting this error because your app uses the legacy org.apache.http.legacy
client and your app's targetSdkVersion
is set to 28
or higher.
Consider using HttpURLConnection
or lowering your targetSdkVersion
in build.gradle
.
来源:https://stackoverflow.com/questions/51591208/noclassdeffounderror-exception-in-android-stuidio