无法在新的Android Studio Project上解析符号GooglePlayServicesClient

Dan*_*ahn 32 android google-play-services android-studio

我刚刚安装了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'
}
Run Code Online (Sandbox Code Playgroud)

Pav*_*dka 41

GooglePlayServicesClientclass已经被弃用了一段时间.有了最新的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();
Run Code Online (Sandbox Code Playgroud)

  • 为Android开发非常糟糕.我必须每隔几个月重写一次我正在处理的项目,因为IDE和SDK的更改完全破坏了一切.已经在我的项目上再坐了5个小时,尝试使用更新的IDE再次编译它.我非常期待iphone的实现 (11认同)