2

Unsure why this would be the case, but this line of code crashes my app in Debug or Run mode:

MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);  

Is there a permission or some other thing I am doing wrong by using this?

I am building for Android 2.1 and using apache-mime4j-dom-0.7.2.jar and httpmime-4.1.3.jar.

Keith Adler
  • 20,880
  • 28
  • 119
  • 189
  • 1
    04-29 14:43:54.434: E/AndroidRuntime(3329): java.lang.NoClassDefFoundError: org/apache/http/entity/mime/MultipartEntity 04-29 14:43:54.434: E/AndroidRuntime(3329): at com.somecompany.someapp.SomeAppActivity.uploadPhoto(SomeActivity.java:496) – Keith Adler Apr 29 '12 at 18:44
  • I have this referenced which is why I am perplexed. The code compiles etc. but always crashes on this line without an exception caught from the Try/Catch. – Keith Adler Apr 29 '12 at 18:45
  • What ADT are you using in Eclipse? You should probably check out this [bug report](http://code.google.com/p/android/issues/detail?id=27490) – Jens Apr 29 '12 at 18:51
  • 1
    possible duplicate of [NoClassDefFondError in Android... but the Class is in one jar included in the Classpath](http://stackoverflow.com/questions/10070788/noclassdeffonderror-in-android-but-the-class-is-in-one-jar-included-in-the-cl) – Keith Adler Apr 29 '12 at 18:51

3 Answers3

9

This is just a guess but i think your problem is related to the new ADT version. As of ADT 17 jars need to be put into the libs folder or they wont be packaged with the apk.

So either put them into libs or go to "configure Build Path.."->"Order and Export" and click the checkboxes next to your jars.

Renard
  • 6,909
  • 2
  • 27
  • 23
2

i had this exact same problem even though my libs were already placed correctly in the right folder. Compile was fine and everything.

My solution was to update my httpmime jar to 4.2.3 (my previous version was 4.0). after that everything works in the app.

kevinl
  • 4,194
  • 6
  • 37
  • 55
0

I had this exact same problem. My libs were placed properly. Java version was 1.6 as needed. Still got the error. So upgraded httpmime to 4.2.5 then downgraded to 4.2.3. Still no luck.

My problem was solved when added the jars to the build path (Properties > Java build path) and then on the order and export tab ticked the jars.

This is not the official way. But this is the way it worked for me:

minSdkVersion="7" targetSdkVersion="17"

ADT build v22.0.0-675183 Platform tools 17

Windows 7 Professional 64 bit

Andras Balázs Lajtha
  • 2,576
  • 25
  • 32