基本上,我有一个完全登录Facebook的应用程序,但是为了我的应用程序按我想要的功能,它还需要登录谷歌。 所以首先,我需要我的应用程序允许我使用本教程登录google / google +: http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/
然而,一旦我调试我的程序,它就会在启动时崩溃,没有Logcat反馈让我知道在运行和调试模式下的位置。 当我取消注释以下代码行时程序崩溃:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API, null)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
这些是addConnectionCallbacks和连接失败的函数
@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) {
// The user has already clicked 'sign-in' so we attempt to
// resolve all
// errors until the user is signed in, or they cancel.
resolveSignInError();
}
}
}
@Override
public void onConnected(Bundle arg0) {
mSignInClicked = false;
Toast.makeText(this, "User is connected!", Toast.LENGTH_LONG).show();
// Get user's information
// getProfileInformation();
// Update the UI after signin
updateUI(true);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RC_SIGN_IN) {
if (resultCode != RESULT_OK) {
mSignInClicked = false;
}
mIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) {
mGoogleApiClient.connect();
}
}
else{
callbackManager.onActivityResult(requestCode, resultCode, data);// for facebook only
}
}
此刻真的让我感到难过,在谷歌工作之前我无法继续我的发展。 我已将这些添加到我的清单中:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:screenOrientation="portrait"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data android:name="com.google.android.gms.appstate.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name" />
我还从keytool生成器输入了正确的appnumber形式的开发控制台和SHA1代码。我还在控制台中启用了google play API。
如果我诚实的话,我想不出还有什么。
提前致谢。