无法在新的 Android Studio 项目上解析符号 GooglePlayServicesClient [英] Cannot resolve symbol GooglePlayServicesClient on new Android Studio Project

查看:31
本文介绍了无法在新的 Android Studio 项目上解析符号 GooglePlayServicesClient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 Android Studio 1.1.0 并创建了一个新项目.我使用包括 Google+ 登录在内的登录活动创建了它.

I just installed Android Studio 1.1.0 and created a new project. I created it with a Login Activity including Google+ login.

项目一打开,我就看到PlusBaseActivity.java 中有很多错误.这些似乎源于 com.google.android.gms.common.GooglePlayServiceClient 未导入这一事实.

As soon as the project opens, I see many errors in PlusBaseActivity.java. These seem to stem around the fact that com.google.android.gms.common.GooglePlayServiceClient is not being imported.

我根本没有更改代码,想知道为什么默认情况下它没有运行.我怎样才能导入它?

I have NOT changed the code at all and wonder why it isn't running by default. How can I get this to import?

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "us.grahn.logintest"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
}

推荐答案

GooglePlayServicesClient 类已弃用一段时间.随着最新的 GooglePlayServices 版本,我相信他们完全摆脱了它.

GooglePlayServicesClient class has been deprecated for some time. With latest GooglePlayServices release I believe they got rid of it completely.

然而,AndroidStudio 中的演示项目仍然使用旧的 API,所以它不会编译 :(

However, demo project in AndroidStudio still uses old APIs, so it won't compile :(

基本上,要与 GooglePlayServices 交谈,您应该使用 GoogleApiClient 现在(如此处所述 https://developer.android.com/google/auth/api-client.html)

Essentially, for talking to GooglePlayServices, you should use GoogleApiClient now (as described here https://developer.android.com/google/auth/api-client.html)

类似于:

GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Plus.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

................

googleApiClient.connect();

这篇关于无法在新的 Android Studio 项目上解析符号 GooglePlayServicesClient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆