无法解析新 Android Studio 项目上的符号 GooglePlayServicesClient
Cannot resolve symbol GooglePlayServicesClient on new Android Studio Project
我刚刚安装了 Android Studio 1.1.0 并创建了一个新项目。我使用登录名 Activity 创建它,包括 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'
}
GooglePlayServicesClient
class 已经弃用一段时间了。随着最新的 GooglePlayServices 发布,我相信他们已经完全摆脱了它。
但是,AndroidStudio中的demo项目仍然使用旧的API,因此无法编译:(
基本上,要与 GooglePlayServices 通信,您应该使用 GoogleApiClient now (as described here 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 Studio 1.1.0 并创建了一个新项目。我使用登录名 Activity 创建它,包括 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'
}
GooglePlayServicesClient
class 已经弃用一段时间了。随着最新的 GooglePlayServices 发布,我相信他们已经完全摆脱了它。
但是,AndroidStudio中的demo项目仍然使用旧的API,因此无法编译:(
基本上,要与 GooglePlayServices 通信,您应该使用 GoogleApiClient now (as described here 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();