Home » Android » Multiple Google Cloud projects in one Android app

Multiple Google Cloud projects in one Android app

Posted by: admin November 1, 2017 Leave a comment

Questions:

Is it possible to have an Android app use Google services from multiple different Google Cloud projects, belonging to different Google accounts? For example one Google Cloud project for sign-in through oauth, and another project for services such as GCM or analytics?

Typically, you setup your google services through the web console, and get a generated google-services.json file that contains both GCM sender ID, oauth client ID’s, API keys etc. This is put in the app folder and in turn generates resources etc used by GoogleApiClient, and perhaps also InstanceIDListener et. al.
But is it possible to use some services from one project and others from another?

A hypothetical usecase could be that organization A creates an Android library that makes use of GCM, analytics etc, connected to organization A’s Google Cloud account. This library is then used in an app created by organization B that wants to use Google sign-in or other services, connected to organization B’s Google Cloud account. But if GCM or analytics code running in the library depends on parameters, api keys etc, how would this be setup? It cannot rely on google-services.json in the app module. It seems that multiple projects could cause conflicts here?

Answers: