Android中的NoClassFoundError MultipartEntity错误
作者:互联网
我无法解决此问题.我添加了以下罐子.
httpClient-4.2.5.jar
httpcore-4.2.4.jar
httpmime-4.2.5.jar
我通过“构建路径”中的“添加外部JAR”选项添加了这些jar,然后在eclipse项目的libs文件夹中手动添加了它们,但在调试以下行时却出现了以下错误.
MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
实际上,我正在尝试使用此将多个图像上传到我的php服务器.
Logcat:
06-26 02:06:08.082: E/AndroidRuntime(20389): FATAL EXCEPTION: IntentService[SyncService]
06-26 02:06:08.082: E/AndroidRuntime(20389): java.lang.NoClassDefFoundError: org.apache.http.entity.mime.MultipartEntity
06-26 02:06:08.082: E/AndroidRuntime(20389): at com.example.cameralibrary.ServerCommunication.uploadUserPhoto(ServerCommunication.java:43)
06-26 02:06:08.082: E/AndroidRuntime(20389): at com.example.cameralibrary.SyncService.onHandleIntent(SyncService.java:38)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.os.Looper.loop(Looper.java:138)
06-26 02:06:08.082: E/AndroidRuntime(20389): at android.os.HandlerThread.run(HandlerThread.java:60)
06-26 02:06:08.082: E/AndroidRuntime(20389): Caused by: java.lang.ClassNotFoundException: org.apache.http.entity.mime.MultipartEntity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.example.cameralibrary-2.apk]
06-26 02:06:08.082: E/AndroidRuntime(20389): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-26 02:06:08.082: E/AndroidRuntime(20389): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-26 02:06:08.082: E/AndroidRuntime(20389): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
解决方法:
发现自己.问题是我不包含READ_EXTERNAL_STORAGE权限.
我在清单中添加了以下行,并且行得通.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
标签:multipartentity,android,image-uploading 来源: https://codeday.me/bug/20191030/1970163.html