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
GooglePlayServicesClient
class已经被弃用了一段时间.有了最新的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)
归档时间: |
|
查看次数: |
24557 次 |
最近记录: |