I am trying to upload image and data to a Django server. I included the apache-mime4j.0.6.jar and httpmime4.0.1.jar (Project-> build path-> Add external jar files) And here is the code for loading the image.
HttpResponse response = null; try { HttpPost httppost = new HttpPost("http://10.0.2.2:8000/mobile"); // HttpPost httppost = new HttpPost("some url"); MultipartEntity multipartEntity = new MultipartEntity(); //MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); multipartEntity.addPart("name", new StringBody("nameText")); multipartEntity.addPart("place", new StringBody("placeText")); multipartEntity.addPart("tag", new StringBody("tagText")); //multipartEntity.addPart("Description", new StringBody(Settings.SHARE.TEXT)); multipartEntity.addPart("Image", new FileBody(destination)); httppost.setEntity(multipartEntity); httpclient.execute(httppost, new PhotoUploadResponseHandler()); } catch (Exception e) { Log.e( "Error","error"); }
Error message:
Could not find class 'org.apache.http.entity.mime.MultipartEntity'
And I tried to manually create the libs folder and manually include the jar files in the / libs folder. When I do this, it does not compile.
Error:
Conversion to Dalvik format failed with error 1 Unknown Android Packaging Problem
I tried to create a new application, including libraries. And I came across the same error. I tried my best. Can someone tell me why this is happening and how to fix it. Any help would be greatly appreciated!
source share