Add External Jar To Android Project In Eclipse
Solution 1:
I solved the issue by following these instructions step-by-step. When I initially began setting up the project:
- I imported the JAR files from the
google-api-java-client
project into my project'slib/
folder - I right-clicked
lib/google-api-client...
and selected Build Path > Add To Build Path
At this point, in Eclipse, a bunch of libraries appear under my project's "Referenced Libraries" section:
jsr305-1.3.9.jar
gson-1.7.1.jar
guava-r09.jar
junit-4.8.2.jar
httpclient-4.0.3.jar
httpcore-4.0.1.jar
commons-logging-1.1.1.jar
commons-codec-1.3.jar
jackson-core-asl-1.9.1.jar
xpp3-1.1.4c.jar
protobuf-java-2.2.0.jar
google-http-client-1.6.0-beta.jar
google-oauth-client-1.6.0-beta.jar
google-api-client-1.6.0-beta.jar
However, when I went to Project > Properties > Java Build Path > Libraries, I saw that only google-api-client...
was listed. When I tried to run the project, I got the NoClassDefFounError
for ApacheHttpTransport
, as mentioned in the original post. This is because that class is defined in google-http-client
!. By manually adding google-http-client
to the build path, the problem is solved.
Lesson learned: just because a JAR is listed under an Eclipse project's "Referenced Libraries" does not mean those JARs are included in the project's build path.
Solution 2:
maybe imports ? ctrl+shift+o does anything?
If not, I'm not sure you must instantiate the good class, with this error
Solution 3:
Yes place the jar(s) in the lib folder and add the project to the build path (properties section of your project. Eclipse will clean and build after. You should see the jar file in use as it will appear in the "libraries" section under the Android library.
To reference use import some.package.com. As letroll says ctrl+shift+o should sort out imports for you.
Post a Comment for "Add External Jar To Android Project In Eclipse"