0

I'm very new to Android Studio, which is the application I'm using to program the app. While following the steps in this video to integrate Google Sign-In to my Android app, I get an error of the form ApiException. In particular, I have an ImageButton which, when pressed, runs the following method:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode == 1000)
    {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try
        {
            task.getResult(ApiException.class);
            //If we log in successfully we navigate to second activity.
            navigateToSecondActivity();
        }
        catch(ApiException e)
        {
            Toast.makeText(getApplicationContext(), "Error_Text", Toast.LENGTH_SHORT).show();
        }
    }
}

When running the app and pressing the ImageButton, a little white rectangle with the text "Error_Text" pops up, meaning that the code has entered the catch-block above, which happens if an ApiException ocurrs.


I am not using Firebase, but many of the codes in posts regarding the similar problems on stackoverflow do, thus some of the solutions I have tried regard codes which use Firebase. I've read this, this and this. In particular, I think I should explain that I've already tried the following solutions:

  1. From the developers.google website I have configured my project with the correct project name and SHA-1 signing certificate (which I copy-pasted from gradle>AppName>Tasks>android>signingReport in Android studio).

  2. The error occurs both in the emulator in Android Studio and after installing the .apk in my phone.

  3. I have made sure that when the application is ran, either in the emulator or the phone, the last version of Google Play Services is installed, as well as that the device is properly connected to the internet.

  4. I do not have a google developer account. I tried to create one to follows the steps in the third post linked, but it costs $25 just to begin the authentificaiton process, which is money I'm not willing to spend.

Leo
  • 217
  • 3
  • 9

0 Answers0