Search code examples
androidauthenticationoauth-2.0google-apigoogle-fit

Google Fit Credentials: works on Production, not on Development


Goal

I am developing an App that works with Google Fit, but for some reason I can't get them both versions to work at the same time.

Before recreating the credentials again, it was the other way around: Development was working and Production wasn't.

Credentials & Google Api

I enabled the Api and added the credentials:

Google Api website

KeyStore

The generated KetStore contains 2 keys, one for production and another one for development. Each one was set in the Credentials page accordingly to its package name (see Android App).

Terminal dump of KeyStore

Android App

Our App has 2 different package names:

  • xxx.yyy.app for Production
  • xxx.yyy.development for Development

This was achieved with the Gradle config, using flavours. This way we have 2 Apps on the mobile for testing purposes.

Question

I have no idea what conflict it's happening that doesn't let me have them both working.

I only have 1 working at the same time, and the one that doesn't work gets CANCELLED result on the LogCat.

Maybe having the same package prefix (xxx.yyy.) is an issue and therefore, reads the wrong credential?

Any suggestions is appreciated. Thanks.


Solution

  • It turned out that Android Studio wasn't using my keystore when compiling the APK. It was still using the default debug.keystore with alias AndroidDebugKey and android password.

    For some reason, it wasn't reading my signing config for the development environment, but it was for production.

    In order to check what signing is each Build Variant using:

    • Open a project

    • Open Gradle tab on the right

    • Expand <your_project> ==> Tasks ==> Android

    • Double click on singingReport (this will create a Gradle type Run/Debug Configuration)

    • Open Gradle Console located in the bottom right

    At this point you should see some of these:

    Variant: developmentDebug
    Config: debug
    Store: /Users/<username>/.android/debug.keystore
    Alias: AndroidDebugKey
    MD5: YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY:YY
    SHA1: XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
    Valid until: <date>
    

    Make sure the SHA1 for each variant is the same as the one specified in the Credentials page.