我刚刚安装了 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/