android stuidio中的NoClassDefFoundError异常

时间:2018-07-30 09:46:05

标签: android android-studio noclassdeffounderror classnotfoundexception

原因:java.lang.NoClassDefFoundError:错误的解析:Lorg / apache / http / impl / client / DefaultHttpClient

我无法解决以下错误:

  

原因:java.lang.NoClassDefFoundError:无法解决以下问题:   Lorg / apache / http / impl / client / DefaultHttpClient;                         在com.medicend.jykra.medicend.Async.Parser.LoginParser.hitWS(LoginParser.java:68)                         在com.medicend.jykra.medicend.Async.Parser.LoginParser.postData(LoginParser.java:50)                         在com.medicend.jykra.medicend.Activity.SignInActivity $ LoginAsync.doInBackground(SignInActivity.java:91)                         在com.medicend.jykra.medicend.Activity.SignInActivity $ LoginAsync.doInBackground(SignInActivity.java:73)                         在android.os.AsyncTask $ 2.call(AsyncTask.java:333)                         在java.util.concurrent.FutureTask.run(FutureTask.java:266)                         在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:245)                         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)                         在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641)                         在java.lang.Thread.run(Thread.java:764)                      原因:java.lang.ClassNotFoundException:在路径上找不到类“ org.apache.http.impl.client.DefaultHttpClient”。   DexPathList [[zip文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/base.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_dependencies_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_resources_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_0_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_1_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_2_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_3_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_4_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_5_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_6_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_7_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_8_apk.apk”,   压缩文件   “ /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.medicend.jykra.medicend-IiBcrMY7QQx4=a9RIM   / system / lib]]                         在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)                         在java.lang.ClassLoader.loadClass(ClassLoader.java:379)                         在java.lang.ClassLoader.loadClass(ClassLoader.java:312)                         在com.medicend.jykra.medicend.Async.Parser.LoginParser.hitWS(LoginParser.java:68)                         在com.medicend.jykra.medicend.Async.Parser.LoginParser.postData(LoginParser.java:50)                         在com.medicend.jykra.medicend.Activity.SignInActivity $ LoginAsync.doInBackground(SignInActivity.java:91)                         在com.medicend.jykra.medicend.Activity.SignInActivity $ LoginAsync.doInBackground(SignInActivity.java:73)                         在android.os.AsyncTask $ 2.call(AsyncTask.java:333)                         在java.util.concurrent.FutureTask.run(FutureTask.java:266)                         在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:245)                         在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)                         在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:641)                         在java.lang.Thread.run(Thread.java:764)                         禁止:java.io.IOException:找不到用于dex位置的原始dex文件   /data/app/com.medicend.jykra.medicend-IiBcrMY7QQm4ixa9RIMICQ==/split_lib_resources_apk.apk                         在dalvik.system.DexFile.openDexFileNative(本机方法)                         在dalvik.system.DexFile.openDexFile(DexFile.java:354)                         在dalvik.system.DexFile。(DexFile.java:101)                         在dalvik.system.DexFile。(DexFile.java:75)                         在dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)                         在dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)                         在dalvik.system.DexPathList。(DexPathList.java:164)                         在dalvik.system.BaseDexClassLoader。(BaseDexClassLoader.java:74)                         在dalvik.system.BaseDexClassLoader。(BaseDexClassLoader.java:65)                         在dalvik.system.PathClassLoader。(PathClassLoader.java:64)                         在com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)   E / AndroidRuntime:位于   com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)                         在android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)                         在android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)                         在android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)                         在android.app.LoadedApk.getClassLoader(LoadedApk.java:810)                         在android.app.LoadedApk.getResources(LoadedApk.java:1032)                         在android.app.ContextImpl.createAppContext(ContextImpl.java:2345)                         在android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)                         在android.app.ActivityThread.access $ 1100(ActivityThread.java:199)                         在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1650)                         在android.os.Handler.dispatchMessage(Handler.java:106)                         在android.os.Looper.loop(Looper.java:193)                         在android.app.ActivityThread.main(ActivityThread.java:6669)                         在java.lang.reflect.Method.invoke(本机方法)                         在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493)                         在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

2 个答案:

答案 0 :(得分:15)

在“应用程序”下的清单文件中添加以下内容:

<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

答案 1 :(得分:1)

您收到此错误,是因为您的应用程序使用旧版org.apache.http.legacy客户端,而您应用程序的targetSdkVersion设置为28或更高。

考虑使用HttpURLConnection或降低targetSdkVersion中的build.gradle