工作,我有這樣的代碼谷歌的登錄不火力地堡
public class SignInActivity extends BaseActivity implements
GoogleApiClient.OnConnectionFailedListener{
private static final String TAG = "SIA";
private static final String USER_ID = "USER_SI_SUCCESS";
private FirebaseAuth mAuth;
private GoogleApiClient mGoogleApiClient;
private static final int RC_SIGN_IN = 103;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
// Initialize authentication and set up callbacks
mAuth = FirebaseAuth.getInstance();
// GoogleApiClient with Sign In
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API,
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(getString(R.string.default_web_client_id))
.build())
.build();
}
public void processSignIn(View view){
Intent intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(intent, RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleGoogleSignInResult(result);
}
}
private void handleGoogleSignInResult(GoogleSignInResult result) {
Log.e(TAG, "handleSignInResult:" + result.getStatus());
if (result.isSuccess()) {
// Successful Google sign in, authenticate with Firebase.
GoogleSignInAccount acct = result.getSignInAccount();
firebaseAuthWithGoogle(acct);
} else {
// Unsuccessful Google Sign In, show signed-out UI
Log.e(TAG, "Google Sign-In failed.");
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
showProgressDialog(getString(R.string.profile_progress_message));
mAuth.signInWithCredential(credential)
.addOnSuccessListener(this, new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult result) {
handleFirebaseAuthResult(result);
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
handleFirebaseAuthResult(null);
}
});
}
public String getUid() {
return FirebaseAuth.getInstance().getCurrentUser().getUid();
}
private void handleFirebaseAuthResult(AuthResult result) {
// TODO: This auth callback isn't being called after orientation change. Investigate.
dismissProgressDialog();
if (result != null) {
Log.e(TAG, "handleFirebaseAuthResult:USER_ID");
Intent porstSIIntent = new Intent(SignInActivity.this, MainActivity.class);
porstSIIntent.putExtra(USER_ID, result.getUser().getUid());
SignInActivity.this.startActivity(porstSIIntent);
} else {
Toast.makeText(this, "Authentication failed.", Toast.LENGTH_SHORT).show();
return;
}
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.e(TAG, "onConnectionFailed:" + connectionResult);
}
}
與
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
//Firebase depedencies
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile 'com.google.firebase:firebase-auth:9.2.1'
compile 'com.google.firebase:firebase-common:9.0.2'
//compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.firebase:firebase-storage:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile 'com.google.android.gms:play-services-location:9.2.1'
///compile 'com.onesignal:OneSignal:[email protected]'
// Required for OneSignal, even if you have added FCM.
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.mikhaellopez:hfrecyclerview:1.0.0'
compile 'com.daimajia.numberprogressbar:library:[email protected]'
compile 'com.atlassian.commonmark:commonmark:0.6.0'
compile 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.6.0'
compile 'com.atlassian.commonmark:commonmark-ext-gfm-strikethrough:0.6.0'
compile 'ren.qinc.edit:lib:0.0.3'
compile project(':drawer')
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.flaviofaria:kenburnsview:1.0.5'
compile 'com.jpardogo.materialtabstrip:library:1.1.1'
}
谷歌登錄。在一切都沒有工作,我正在以下日誌
E/SIA: handleSignInResult:Status{statusCode=unknown status code: 12501, resolution=null}
E/SIA: Google Sign-In failed.
重要:幾個月前這個代碼工作,但現在它不會。我不知道爲什麼。請指導我。
'火力常見:9.0.2'' <<需要與其他火力點版本(雖然你也可以將其刪除;其他人包括'common') –
請檢查。我希望這可以幫助你https://github.com/devfd/react-native-google-signin/issues/22 – Shailesh
狀態12501經常表明你的google-services.json文件中定義的配置有問題。檢查包名稱,SHA1密鑰等的值。也許嘗試生成並下載新文件。 –