Android :java.lang.RuntimeException: An error occurred while executing doInBackground()

android 项目在使用拍照功能时,遇到下面问题:

java.lang.RuntimeException: An error occurred while executing doInBackground()
       	at android.os.AsyncTask$3.done(AsyncTask.java:353)
       	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 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       	at java.lang.Thread.run(Thread.java:764)
       	at com.unionbroad.app.util.SendFileManager$TaskThreadFactory$1.run(SendFileManager.java:78)
       Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/Consts;
       	at org.apache.http.entity.mime.content.StringBody.(StringBody.java:148)
       	at com.unionbroad.app.util.SendFileManager$UploadFileToServer.uploadFile(SendFileManager.java:477)
       	at com.unionbroad.app.util.SendFileManager$UploadFileToServer.doInBackground(SendFileManager.java:448)
       	at com.unionbroad.app.util.SendFileManager$UploadFileToServer.doInBackground(SendFileManager.java:417)
       	at android.os.AsyncTask$2.call(AsyncTask.java:333)
       	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       	... 4 more
       Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.Consts" on path: DexPathList[[zip file "/data/app/com.******.***-5-d7PlREbGhWqcG72zsO3A==/base.apk"],nativeLibraryDirectories=[/data/app/com.******.***-5-d7PlREbGhWqcG72zsO3A==/lib/arm, /system/fake-libs, /data/app/com.greatzee.poc-5-d7PlREbGhWqcG72zsO3A==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
       	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
       	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
       	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
       	... 10 more

解决方法:
build.gradle中引入下面这句:
implementation ‘org.apache.httpcomponents:httpclient-android:4.3.5’

你可能感兴趣的:(Android相关,android)