I write app on android which will send xml file to PHP server. Here is my code:
InputStream is = new FileInputStream(file);
HttpClient httpClient = new DefaultHttpClient();
HttpPost postReq = new HttpPost("http://majkelsoftgames.cba.pl/ser/server.php");
byte[] data = IOUtils.toByteArray(is);
InputStreamBody isb= new InputStreamBody(new ByteArrayInputStream(data), "file");
MultipartEntity multipartContent = new MultipartEntity();
multipartContent.addPart("file", isb);
postReq.setEntity(multipartContent);
HttpResponse response = httpClient.execute(postReq);
My problem is that when
byte[] data = IOUtils.toByteArray(is);
is executing I get:
java.lang.NoClassDefFoundError: org.apache.commons.io.IOUtils
I downloaded external commons-io.jar from http://commons.apache.org/io/ and added this jar to the java build path in android project. I really have no idea what I am doing wrong. Do you have any idea how can I fix it?
You added it to the build path, but did you place it in the /libs directory of youur project? That is the only way it will get added to your apk.