我已在我的代码中添加了所有必需的配置以应用google plus身份验证。不幸的是,身份验证过程每次都返回handleSignInResult:false
。我列出了我为google plus身份验证配置项目所做的所有步骤。
在项目级别gradle中,我添加了......
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
并在app level gradle中添加了
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
}
apply plugin: 'com.google.gms.google-services'
我的服务器客户端ID看起来像xxxxxxx-n7i6lyyyyyyyyy.apps.googleusercontent.com
,我从 OAuth 2.0客户端ID
Web client 1 Mar 12, 2016 Web application xxxxxxx-n7i6lyyyyyyyyy.apps.googleusercontent.com
我还在项目的应用目录中添加了 google-services.json /app
并将以下权限添加到项目清单
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
每次转到onConnectionFailed
方法并返回handleSignInResult:false
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.d(TAG, "onConnectionFailed:" + connectionResult);
}
我的项目默认使用gradle-2.10。所以,我使用的是gms:play-services:8.3.0而不是gms:play-services:8.4.0。
有谁能告诉我这里出了什么问题?
答案 0 :(得分:1)
我也遇到了同样的问题,然后我更新了下面给出的代码,也可以在一些演示中找到
<div class="home-navigation">
<a href="news.html"><div class="home-navigation-item"> NEWS </div></a>
<a href="announcements.html"><div class="home-navigation-item"> ANNOUNCEMENTS </div></a>
<a href="events.html"><div class="home-navigation-item"> SCHEDULE OF EVENTS</div></a>
</div>
并且也这样做
@Override
public void onConnectionFailed(ConnectionResult result) {
if (!result.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this,
0).show();
return;
}
if (!mIntentInProgress) {
// Store the ConnectionResult for later usage
mConnectionResult = result;
if (mSignInClicked) {
resolveSignInError();
}
}
}
/**
* Method to resolve any sign in errors
* */
private void resolveSignInError() {
if (mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
mConnectionResult.startResolutionForResult(this, RC_SIGN_IN);
} catch (SendIntentException e) {
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
如果你还没有这样做,试试这个
并检查是否已调用onActivityResult方法