Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassFoundError MultipartEntity error in android

I am not able to figure this problem out.I added the following jars.

httpClient-4.2.5.jar
httpcore-4.2.4.jar
httpmime-4.2.5.jar

I added these jar through Add External JARs option in Build Paths and then added them manually in the libs folder of my eclipse project still it gives me the following error while debugging the following line.

MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

Actually I am trying to upload multiple images to my php server using this.

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)
like image 848
Mj1992 Avatar asked Dec 06 '25 15:12

Mj1992


1 Answers

Found out myself.The problem was that I didn't include the READ_EXTERNAL_STORAGE permission. I added the following line in my manifest and it worked.

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
like image 76
Mj1992 Avatar answered Dec 10 '25 00:12

Mj1992



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!