无法解决以下问题:Lorg / apache / http / client / methods / HttpPost

时间:2018-09-28 05:51:50

标签: android http-post retrofit

在所有8.1及以下版本的android设备中都可以使用httpPost,但是在android 9.0中运行时出现以下错误,

Failed resolution of: Lorg/apache/http/client/methods/HttpPost;
        at com.makemusiccount.android.retrofit.RestClient.Execute(RestClient.java:99)
        at com.makemusiccount.android.activity.LoginActivity$Login.doInBackground(LoginActivity.java:390)
        at com.makemusiccount.android.activity.LoginActivity$Login.doInBackground(LoginActivity.java:368)
        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.client.methods.HttpPost" on path: DexPathList[[zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/base.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_resources_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.makemusiccount.android-HYy0YZQPLivvJM2dD3B3ZA==/lib/x86, /system/lib]]

1 个答案:

答案 0 :(得分:6)

将此行添加到manifest.xml的应用程序标记中

<uses-library android:name="org.apache.http.legacy" android:required="false"/>