image - NoClassDefFoundError on MultiPart compilable method in Android -
i'm dealing following problem: when trying upload image through multipart entity , seems several updates on httpclient/mime cracking everything. i'm trying following code, fails noclassdeffounderror:
public static void executemultipartpost(file image, arraylist<cookie> cookies, string myurltopost) { try { // post instance httppost httppost = new httppost(myurltopost); // setting cookies connection session if (cookies != null && cookies.size() > 0) { string cookiestring = ""; (int i=0; i<cookies.size(); ++i) { cookiestring += cookies.get(i).getname()+"="+cookies.get(i).getvalue()+";"; } cookiestring += "domain=" + baseurl + "; " + "path=/"; httppost.addheader("cookie", cookiestring); } // creating http client httpclient httpclient = new defaulthttpclient(); // creating multientity part [error occurs in bellow line] multipartentity multipartentity = new multipartentity(); multipartentity.addpart("photoupload", new filebody(image)); httppost.setentity(multipartentity); httpresponse response = httpclient.execute(httppost); httpentity resentity = response.getentity(); } catch (exception e) {} } this method compilable , uses httpclient-4.0.1.jar , httpmime-4.2.jar libs, again, crashes on commented line me.
am missing something?
ok, here have libraries needed multipart post, credits satya komatineni , david maclean, writers of pro android 3 , 4 , quote book
to multipart post calls, need 3 additional apache open source projects: apache commons io, mime4j, , httpmime. can download these projects following web sites: commons io: http://commons.apache.org/io/ mime4j: http://james.apache.org/mime4j/ httpmime: http://hc.apache.org/downloads.cgi (inside of httpclient)
Comments
Post a Comment