Я успешно использовал старую версию firebase auth ui, но после обновления до последних выпусков я получаю следующую ошибку при попытке войти в систему с помощью Google:
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Code: 10, message: 10:
at com.firebase.ui.auth.data.remote.GoogleSignInHandler.onActivityResult(GoogleSignInHandler.java:106)
at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onActivityResult(AuthMethodPickerActivity.java:225)
at android.app.Activity.dispatchActivityResult(Activity.java:7235)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4320)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4367)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1649)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Facebook и вход по электронной почте в порядке.
Я использую следующие зависимости в моем приложении gradle:
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.facebook.android:facebook-login:4.32.0'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
И следующее в моем проекте gradle:
classpath 'com.google.gms:google-services:4.0.1'
Активность при входе:
public class ActivityLoginView extends ActivityBase {
// Misc
public static final int RC_SIGN_IN = 100;
public static final String TAG = "ActivityLoginView";
public ActivityLoginViewModel activityLoginViewModel;
private static final String PRIVACY_POLICY_URL = "https://www.editedout.com/pages/privacy";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
activityLoginViewModel = new ActivityLoginViewModel(this);
if (!activityLoginViewModel.isGooglePlayServicesAvailable()) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("No Google Play Services");
alertDialog.setMessage("This app requires Google Play Services to be installed and enabled");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
System.exit(0);
}
});
alertDialog.show();
} else {
FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
// See if user is logged in already
if (currentUser != null) {
// User already signed in
if (!BuildConfig.DEBUG) {
Crashlytics.setUserIdentifier(currentUser.getUid());
Crashlytics.setUserName(currentUser.getDisplayName());
Crashlytics.setUserEmail(currentUser.getEmail());
}
activityLoginViewModel.saveUserToFirebase();
} else {
startActivityForResult(
AuthUI.getInstance().createSignInIntentBuilder()
.setTheme(R.style.LoginTheme)
.setLogo(R.drawable.loginlogo)
.setAvailableProviders(getSelectedProviders())
.setPrivacyPolicyUrl(PRIVACY_POLICY_URL)
.setIsSmartLockEnabled(!BuildConfig.DEBUG)
.build(),
RC_SIGN_IN);
}
}
}
public void startMain() {
if (SPManager.getBoolean(this, SPManager.kOnBoardShown)) {
Intent intent = new Intent(this, ActivityHomePage.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
} else {
startActivity(ActivityOnBoard.newIntent(this));
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
handleSignInResponse(resultCode, data);
}
}
private void handleSignInResponse(int resultCode, Intent data) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == RESULT_OK) {
activityLoginViewModel.saveUserToFirebase();
} else {
// Sign in failed
if (response == null) {
// User pressed back button
showSnackbar(R.string.sign_in_cancelled);
return;
}
if (response.getError().getErrorCode() == ErrorCodes.NO_NETWORK) {
showSnackbar(R.string.no_internet_connection);
return;
}
showSnackbar(R.string.unknown_error);
Log.e(TAG, "Sign-in error: ", response.getError());
}
}
private List<AuthUI.IdpConfig> getSelectedProviders() {
List<AuthUI.IdpConfig> selectedProviders = new ArrayList<>();
selectedProviders.add(new AuthUI.IdpConfig.GoogleBuilder()
.build());
selectedProviders.add(new AuthUI.IdpConfig.FacebookBuilder()
.build());
selectedProviders.add(new AuthUI.IdpConfig.EmailBuilder()
.setRequireName(true)
.setAllowNewAccounts(true)
.build());
//selectedProviders
// .add(new AuthUI.IdpConfig.PhoneBuilder().build());
return selectedProviders;
}
public void showSnackbar(@StringRes int errorMessageRes) {
View parentLayout = findViewById(android.R.id.content);
Snackbar.make(parentLayout, errorMessageRes, Snackbar.LENGTH_LONG).show();
}
@Override
public void onBackPressed() {
finishAffinity();
}