DEV Community

Alonso Ato Neyra
Alonso Ato Neyra

Posted on

Google Sign-in for android app with flavours

I work for a local bussiness in Peru. I'm developing a android app so my product owner tell me that the bussiness needed a new funcionality for the delivery app. He told that the app needed a Google sign-in The requerimient looked easy because I've already done that in another apps, so I think this is easy.

So I followed the steps from this page:

Google Sign-in for Android:

I tought that it would take me at least at few hours but I couldnt. I did all the steps in the google's guide but ALWAYS throw me this message:

com.google.android.gms.common.api.ApiException: 10:

I was strugglin about two days, reading a lot of post of SO, fixing my code, trying new ways to achive the google sign in but nothig worked. Actually, I created a simple demo app just to try the google sign-in and this demo worked fine! I was really frustated.

At the second day, in the afternoon, around the 14:00 hours, FINALLY I found the solution and I hope this can help you my dear android developer.

The delivery app works with flavours. This may sound normal, but when you configure your app to use Google sign-in, the ask you for the package that you're using in your app. And HERE IS THE KEY:

When you use flavours, you create package for each one. I was working in a dev flavour so my package was

dev.mydeliveryapp.peru

But in the console I register the production flavour:

mydeliveryapp.peru

When I changed that, and tried again, the google sign-in works fine.

Also, just in case you didn't know, you shoul register your SHA1.
In the android studio, to the right there is an gradle option option as you can see in the image.

views-sktech


Fig. 1

Then, click in sigin report and the console will shoy you your SHA1:

views-sktech


Fig. 1

So that's all. I hope this help someone out there strugglin with this.

Happy code!

Discussion (0)