【问题标题】:Cannot resolve symbol GooglePlayServicesClient on new Android Studio Project无法在新的 Android Studio 项目上解析符号 GooglePlayServicesClient
【发布时间】:2015-03-27 14:45:30
【问题描述】:

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

项目一打开,我就在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'
}

【问题讨论】:

  • @PavelDudka 我已经包含了 build.gradle 文件。我根本没有编辑过这个。

标签: android android-studio google-play-services


【解决方案1】:

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 开发是可怕的。我必须每隔几个月就完全重写我正在从事的项目,因为 IDE 和 SDK 的更改完全破坏了一切。已经在我的项目上再坐了 5 个小时,试图用更新的 IDE 再次编译它。我很期待iphone的实现
  • @John 让我们保持最新状态
  • @John 使用干净的架构,这样你只需要更改一个类中的代码。
猜你喜欢
  • 2015-05-30
  • 1970-01-01
  • 2014-10-07
  • 2017-03-23
  • 2018-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多