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

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

问题描述

我刚刚安装的Andr​​oid 1.1.0工作室,并创建了一个新的项目。我创造了它与登录活动包括Google+的登录。

只要项目打开,我看到 PlusBaseActivity.java 许多错误。这些似乎阻止周围的<​​code> com.google.android.gms.common.GooglePlayServiceClient 不被导入的事实。

我并没有改变code在所有的,不知道为什么它默认情况下不运行。我怎样才能得到这个导入?

build.gradle

 应用插件:com.android.application

安卓{
    compileSdkVersion 22
    buildToolsVersion22.0.1

    defaultConfig {
        的applicationIDus.grahn.logintest
        的minSdkVersion 16
        targetSdkVersion 22
        版本code 1
        VERSIONNAME1.0
    }
    buildTypes {
        推出 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'proguard-rules.pro
        }
    }
}

依赖{
    编译文件树(导演:库,包括:['的* .jar'])
    编译com.android.support:appcompat-v7:22.0.0
    编译com.google.android.gms:播放服务:7.0.0
}
 

解决方案

GooglePlayServicesClient 类是pcated一段时间去$ P $。随着最新GooglePlayServices版本我相信他们摆脱它完全。

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

从本质上讲,对于说话GooglePlayServices,你应该使用<一个href="https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html">GoogleApiClient现在(如这里描述<一href="https://developer.android.com/google/auth/api-client.html">https://developer.android.com/google/auth/api-client.html)

是这样的:

  GoogleApiClient googleApiClient =新GoogleApiClient.Builder(本)
            .addApi(Plus.API)
            .addConnectionCallbacks(本)
            .addOnConnectionFailedListener(本)
            。建立();

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

googleApiClient.connect();
 

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

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 class was deprecated for some time. With latest GooglePlayServices release I believe they got rid of it completely.

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

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

Something like:

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

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

googleApiClient.connect();

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

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