无法解析新 Android Studio 项目上的符号 GooglePlayServicesClient

2023-12-31

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

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

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

构建.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 版本的发布,我相信他们完全摆脱了它。

但是,AndroidStudio 中的演示项目仍然使用旧的 API,因此无法编译:(

本质上,为了与 GooglePlayServices 对话,您应该使用谷歌API客户端 https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html现在(如此处所述https://developer.android.com/google/auth/api-client.html 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();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法解析新 Android Studio 项目上的符号 GooglePlayServicesClient 的相关文章

随机推荐