问题
I am in a weird situation, which I have no idea what's going on.
The code was working, until I upgraded my Android SDK to r17.
The code is able to compile, but during runtime, Eclipse throws ClassNotFoundException()
, under findClass method, in PathClassLoader.class
The class that not found are "org.apache.http.entity.mime.content.ContentBody" and "org.apache.http.entity.mime.content.StringBody"
I already imported in the latest (4.1.3) http components jar file into project-> properties-> java build path-> add external jar,
and also clear my project N-times, yet nothing seems work.
This is from the logcat:
03-27 17:31:32.461: W/dalvikvm(14263): VFY: unable to find class referenced in signature (Lorg/apache/http/entity/mime/content/ContentBody;)
03-27 17:31:33.802: E/dalvikvm(14263): Could not find class 'org.apache.http.entity.mime.content.StringBody', referenced from method com.milotin.core.base.MTBaseNetworkUtilities.getContentBody
03-27 17:31:33.802: W/dalvikvm(14263): VFY: unable to resolve new-instance 710 (Lorg/apache/http/entity/mime/content/StringBody;) in Lcom/milotin/core/base/MTBaseNetworkUtilities;
(sorry for the messy paste, is actually just 3 lines from logcat)
My TargetSDK is API10, and MinSDK is API8.
What is the reason??
回答1:
Yes!! r17 is the culprit!! I used to put those .jar files outside my project, now I moved them into my project/lib folder, and problem solved. Here is where I got my solution: Jar-file issue with ADT r17
Thanks!
来源:https://stackoverflow.com/questions/9886928/android-classnotfoundexception-for-httpcomponents