javaandroidgoogle-http-client

google-http-java-client usage for android


Has anyone used google http client for android recently. I downloaded the latest version, but missing the jar.

google-http-client-android3-1.12.0-beta.jar

According to the doc, I need to import

google-http-client-1.12.0-beta.jar
google-http-client-android2-1.12.0-beta.jar (only for SDK >= 2.1)
google-http-client-android3-1.12.0-beta.jar (only for SDK >= 3.0)
gson-2.1.jar
guava-11.0.1.jar
jackson-core-asl-1.9.4.jar
jsr305-1.3.9.jar
protobuf-java-2.2.0.jar

Solution

  • First, Download google-http-java-client-1.12.0-beta.zip and extract it on your computer. Read the readme.html for directions. This zip file contains the client library class jars and their associated source jars for each artifact. Similarly the class and source jars for the dependencies are found in the dependencies folder, including licenses.

    Eclipse users will want to set the "Source attachment" for each class jar to its corresponding "-sources" jar.

    For Android, it is important to know which dependencies are compatible with Android and specifically which SDK level. The following are the jars from the dependencies folder required for android applications (or a newer compatible version of each dependency):

    google-http-client-1.12.0-beta.jar
    google-http-client-android2-1.12.0-beta.jar (only for SDK >= 2.1)
    google-http-client-android3-1.12.0-beta.jar (only for SDK >= 3.0)
    gson-2.1.jar
    guava-11.0.1.jar
    jackson-core-asl-1.9.4.jar
    jsr305-1.3.9.jar
    protobuf-java-2.2.0.jar
    

    WARNING: for Android, the jars MUST be placed in a directory named "libs" for the APK packager to find them. Otherwise, you will get a NoClassDefFoundError at runtime.