Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)

Cover Image for Flutter and google_sign_in plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null)
Matheus Mello
Matheus Mello
published a few days ago. updated a few hours ago

Troubleshooting Flutter and google_sign_in Plugin: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null) 🐛🚧

Hey there! Having trouble with your Flutter app and the google_sign_in plugin? Don't worry, we've got your back! 👊 In this blog post, we'll help you troubleshoot and solve the PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null) error. Let's dive right in! 🏊‍♂️

Understanding the Problem 🕵️‍♂️

This error occurs when using the google_sign_in plugin to authenticate with Google, but the sign-in operation fails. The stack trace you provided shows that the error is thrown at this line of code:

await _googleSignIn.signIn();

The error message you're seeing is: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10:, null). This error usually stems from issues with the Google Play Services on the Android device.

Possible Solutions 💡

To fix the PlatformException(sign_in_failed) error, you can try the following solutions:

1. Update Google Play Services ⬆️

Make sure the Google Play Services on the Android device are up to date. An outdated version of Google Play Services could cause authentication errors. To update Google Play Services, follow these steps:

  1. On your Android device, open the Google Play Store.

  2. Tap the menu icon (three lines) in the top-left corner of the screen.

  3. Tap "My apps & games."

  4. Under the "Updates" tab, locate "Google Play Services" and tap the "Update" button if available.

2. Enable Google Play Services on the Virtual Device 📱

If you're testing your app on an Android emulator, make sure that Google Play Services is enabled on the virtual device. Here's how you can do it:

  1. Open the Android Virtual Device Manager (AVD).

  2. Click on the pencil icon (Edit) next to your virtual device.

  3. In the "Hardware" section, click the "New" button.

  4. Select "Play Store" from the dropdown menu and click "Finish."

  5. Click "Finish" again to save the changes.

  6. Launch the virtual device and run your app again.

3. Check the SHA-1 Fingerprint 🔑

Ensure that the SHA-1 fingerprint of your Android app is added to the Firebase project. To check and add the SHA-1 fingerprint, follow these steps:

  1. Open the Firebase console and go to your project.

  2. Click on the gear icon (Settings) in the top-left corner and select "Project settings."

  3. Scroll down to the section "Your apps" and select the Android app.

  4. If the SHA-1 fingerprint is missing, click on "Add fingerprint" and follow the instructions to add it.

4. Enable the Required APIs in the Google APIs Console ⚙️

Ensure that the necessary APIs are enabled in the Google APIs Console. Since you mentioned needing the Google Drive API, make sure it is enabled. To enable the API, follow these steps:

  1. Go to the Google APIs Console.

  2. Select your project.

  3. In the sidebar, click on "Library."

  4. Search for the required API (e.g., Google Drive API) and click on it.

  5. Click the "Enable" button if the API is not already enabled.

5. Check Your Package Name and SHA-1 Key Match 🔑

Make sure the package name in your Firebase project matches the package name in your Flutter app, and the corresponding SHA-1 fingerprint is added to the project. To check and update these details, follow these steps:

  1. Open the Firebase console and go to your project.

  2. Click on the gear icon (Settings) in the top-left corner and select "Project settings."

  3. Scroll down to the section "Your apps" and select the Android app.

  4. Verify that the package name matches the one in your Flutter code.

  5. If the package name is incorrect, click on "Register app" and follow the instructions to add the correct package name.

Conclusion and Call-to-Action 🏁📣

We hope these solutions helped you resolve the PlatformException(sign_in_failed) error with the google_sign_in plugin in your Flutter app. Now, it's time for you to give it a try and let us know if it worked for you! 🤞

If you have any further questions or run into any other issues, feel free to leave a comment below. We're here to help you out! Happy coding! 😄🚀


More Stories

Cover Image for How can I echo a newline in a batch file?

How can I echo a newline in a batch file?

updated a few hours ago
batch-filenewlinewindows

🔥 💻 🆒 Title: "Getting a Fresh Start: How to Echo a Newline in a Batch File" Introduction: Hey there, tech enthusiasts! Have you ever found yourself in a sticky situation with your batch file output? We've got your back! In this exciting blog post, we

Matheus Mello
Matheus Mello
Cover Image for How do I run Redis on Windows?

How do I run Redis on Windows?

updated a few hours ago
rediswindows

# Running Redis on Windows: Easy Solutions for Redis Enthusiasts! 🚀 Redis is a powerful and popular in-memory data structure store that offers blazing-fast performance and versatility. However, if you're a Windows user, you might have stumbled upon the c

Matheus Mello
Matheus Mello
Cover Image for Best way to strip punctuation from a string

Best way to strip punctuation from a string

updated a few hours ago
punctuationpythonstring

# The Art of Stripping Punctuation: Simplifying Your Strings 💥✂️ Are you tired of dealing with pesky punctuation marks that cause chaos in your strings? Have no fear, for we have a solution that will strip those buggers away and leave your texts clean an

Matheus Mello
Matheus Mello
Cover Image for Purge or recreate a Ruby on Rails database

Purge or recreate a Ruby on Rails database

updated a few hours ago
rakeruby-on-railsruby-on-rails-3

# Purge or Recreate a Ruby on Rails Database: A Simple Guide 🚀 So, you have a Ruby on Rails database that's full of data, and you're now considering deleting everything and starting from scratch. Should you purge the database or recreate it? 🤔 Well, my

Matheus Mello
Matheus Mello