E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NoClassDefFoundError: org.apache.http.entity.mime.HttpMultipartMode
at org.apache.http.entity.mime.MultipartEntity.<init>(MultipartEntity.java:91)
at com.greencubes.greendesk.AndroidMultiPartEntity.<init>(AndroidMultiPartEntity.java:19)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.uploadFile(FirstFragment.java:244)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.doInBackground(FirstFragment.java:233)
at com.greencubes.greendesk.FirstFragment$UploadFileToServer.doInBackground(FirstFragment.java:211)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
答案 0 :(得分:1)
如果您使用的是库,则需要将其放入/ libs文件夹。 从http://hc.apache.org/downloads.cgi
下载httpmime,httpcore和httpclient库希望这会有所帮助,因为我在工作室里有相同的jar文件。
如果您正在使用Eclipse,则添加所有jar文件以构建路径。
谢谢,
答案 1 :(得分:0)
Apache HTTP客户端是removed in Lollipop。建议改用HttpUrlConnection。
如果必须使用它,您可以添加:
android {
useLibrary 'org.apache.http.legacy'
}
到你的build.gradle文件。