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

标签 android android-studio google-play-services

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

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

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

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 发布,我相信他们完全摆脱了它。

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

基本上,要与 GooglePlayServices 对话,您应该使用 GoogleApiClient现在(如此处所述 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 - 无法在新的 Android Studio 项目上解析符号 GooglePlayServicesClient,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29303427/

相关文章:

android - 我的 Android 应用无法识别 R.string 资源 - 可能是什么原因?

android - 在 Android 应用程序中处理来电

android - 安全异常 : Not allowed to start Service

flutter - 找不到参数的方法 id() [com.google.gms.google-services]

android - 在 Google Play 服务中找不到 libproject 31

android - 在 Android undefined reference 上使用 FFTW

android-studio - Android Studio安装向导停留在下载组件上

Android 模拟器不能在 MacOS Monterey 上运行?

Android Studio 1.x AVD 未运行?

android - 编译play-services-gcm :8. 4.0 时出现版本冲突错误