google-services
google-services copied to clipboard
Android sign in with Google fails when do install the application from the store only
The problem is only happening with Google sign in " all other providers are working " and google sign in also working on both debug and release APKs but when download the application from the store it produce an error " An unknown error has occurred ". I can't debug it since it only happens when download the application from the store.
I am certainly sure of SHA1 for release since its working when i just copy the release APK and install it manually.
Relevant Code to our sign in activity :
` public class AuthUIActivity extends AppCompatActivity {
private CallbackManager callbackManager;
private boolean authWithFb = false;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
signIn();
initFbLoginButton();
}
private void initFbLoginButton() {
callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager,
new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// App code
authWithFb = true;
}
@Override
public void onCancel() {
// App code
}
@Override
public void onError(FacebookException exception) {
// App code
}
});
}
private void signIn() {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setLogo(R.drawable.transparent)
.setTheme(R.style.auth_theme)
.setAvailableProviders(Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.TwitterBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build()
//Todo Here is the place to add more providers
))
.build(),
RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RC_SIGN_IN) {
handleSignInResponse(resultCode, data);
}
if (authWithFb) {
callbackManager.onActivityResult(requestCode, resultCode, data);
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
protected void onResume() {
super.onResume();
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
startSignedInActivity();
finish();
}
}
private void handleSignInResponse(int resultCode, Intent data) {
IdpResponse response = IdpResponse.fromResultIntent(data);
// Successfully signed in
if (resultCode == RESULT_OK) {
Toast.makeText(this, R.string.txt_welcom, Toast.LENGTH_SHORT).show();
startSignedInActivity();
finish();
} else {
// Sign in failed
if (response == null) {
// User pressed back button
Toast.makeText(this, R.string.txt_sign_in_again, Toast.LENGTH_SHORT).show();
return;
}
if (Objects.requireNonNull(response.getError()).getErrorCode() == ErrorCodes.NO_NETWORK) {
Toast.makeText(this, R.string.txt_require_internet, Toast.LENGTH_SHORT).show();
}
if (Objects.requireNonNull(response.getError().getErrorCode()) == ErrorCodes.PROVIDER_ERROR) {
Toast.makeText(this, R.string.txt_require_internet, Toast.LENGTH_SHORT).show();
}
}
}
private void startSignedInActivity() {
startActivity(new Intent(this, MainActivity.class));
}
} `
False alarm. Just figured that i need a SHA1 for signing too, very complicated process but its working now.