4

I have to implement this method, but most of libs are deprecated. I need a new version compatible with client 1.15.0rc.

public static HttpRequestFactory createRequestFactory(
        final HttpTransport transport) {
    return transport.createRequestFactory(new HttpRequestInitializer() {
        public void initialize(HttpRequest request) {
            GoogleHeaders headers = new GoogleHeaders();
            headers.setApplicationName("AndroidHive-Places-Test");
            request.setHeaders(headers);
            JsonHttpParser parser = new JsonHttpParser(new JacksonFactory());
            request.addParser(parser);
        }
    });
}

The things I can't solve are:

GoogleHeaders headers = new GoogleHeaders();

and

JsonHttpParser parser = new JsonHttpParser(new JacksonFactory());
rickymarchiori
  • 103
  • 2
  • 13

1 Answers1

6

I'm also running the same problem here. So far I have solved the json dependencies adding the following library:

<dependency>
   <groupId>com.google.http-client</groupId>
   <artifactId>google-http-client-jackson</artifactId>
   <version>1.15.0-rc</version>
</dependency>

and replacing:

JsonHttpParser parser = new JsonHttpParser(new JacksonFactory());
request.addParser(parser);

with:

JsonObjectParser parser = new JsonObjectParser(new JacksonFactory());
request.setParser(parser);

I'll let you know how to solve the GoogleHeaders dependency as soon as I solve it myself.

EDIT: It looks like they removed this class in release 1.14 (see this issue) in favor of HttpHeader. Change GoogleHeaders with HttpHeader and replace setApplicationName with setUserAgent, like below:

HttpHeaders headers = new HttpHeaders();
headers.setUserAgent("AndroidHive-Places-Test");
txuslee
  • 416
  • 3
  • 5
  • Import errors are gone :) but I got a doubt because JacksonFactory.class is at google-http-client-jackson2-1.18.0-rc and google-http-client-jackson1-1.18.0-rc. What's the difference between these jars? – Rafael Ruiz Tabares Apr 26 '14 at 11:32