Android and Google client API NetHttptransport Class not found

前端 未结 4 1245
北恋
北恋 2020-12-10 10:15

I am trying to use the Google generated API library for the first time for Android. I have taken code from the the Sample Program provided by Google. My code looks like

相关标签:
4条回答
  • 2020-12-10 10:18

    May be a bit late for this one, but the the jar that you're looking for is google-http-client-1.5.0-beta.jar

    This jar defines com.google.api.client.http.* and com.google.api.client.json.*

    0 讨论(0)
  • 2020-12-10 10:30

    Here is a list of the libraries you should have in you project: http://code.google.com/p/google-api-java-client/wiki/Setup

    0 讨论(0)
  • 2020-12-10 10:42

    You must explicit add library reference of google-http-client-1.5.0-beta.jar(right click project->Properties->Java Build Path->Add External JARs), don't believe class path. If you do not do this, in the apk file does not contain the required data。
    You can download Google plus library from here google-plus-java-starter_v5.zip enter image description here

    0 讨论(0)
  • 2020-12-10 10:42
    plus = Plus.builder(transport, jsonFactory).setApplicationName("Google-PlusSample/1.0")
        .setHttpRequestInitializer(accessProtectedResource)
        .setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() {
            @Override
            public void initialize(JsonHttpRequest request) {
                PlusRequest plusRequest = (PlusRequest) request;
                plusRequest.setPrettyPrint(true);
            }
        }).build();
    

    use this instead of

    Plus plus = new Plus(new NetHttpTransport(), new JacksonFactory());
    
    0 讨论(0)
提交回复
热议问题