我已将Android应用程序从26个SDK升级到了28个。
它在23-27版本中很好用。
但是新版本将在SDK 28中崩溃。
这是异常堆栈:
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)
请帮助我。
答案 0 :(得分:1)
如果您使用的是Apache HTTP客户端,请在AndroidManifest.xml中添加以下内容: refer this
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
答案 1 :(得分:0)
您可以在模块的 build.gradle 中添加以下行:
class="phone_mobile"
并且不要忘记将 minSdkVersion 升级到 23 ,如以下链接所示:
https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p