在Android中使用GoogleHeaders时要包含哪些内容?

时间:2016-10-24 10:08:08

标签: android android-studio gradle dependencies

我正在开发一个应用程序,该应用程序使用了一些google api组件,而build.gradle中的其他依赖项目前看起来就是这样:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile ('com.google.api-client:google-api-client:1.22.0') {
    exclude module: 'httpclient' //by artifact name
    exclude group: 'org.apache.httpcomponents' //by group
    exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}
compile 'com.google.android.gms:play-services:7.8.0'
testCompile 'junit:junit:4.12'

}

不过,我想使用GoogleHeaders类,但Android Studio无法识别它(无法解析符号' GoogleHeaders'):

public void initialize(HttpRequest request) {
            GoogleHeaders headers = new GoogleHeaders();
            headers.setApplicationName("AndroidHive-Places-Test");
            request.setHeaders(headers);
            JsonObjectParser parser = new JsonObjectParser(new JacksonFactory());
            request.setParser(parser);
        }

我应该添加更多依赖项吗? 提前致谢

1 个答案:

答案 0 :(得分:0)

了解google API客户端库

Google API client details