Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use external google-services.json file in library

I'm sharing a single login module across my apps, with a LoginActivity that handles both Facebook and Google auth (logic + UI).
Now, with Facebook it's easy to specify a different ID for each app, overriding the library's facebook_app_id string in the app module.

I didn't find a way to do the same with Google Sign-In because it requires a google-services.json file. In fact, the build fails if I include the file in the app modules and not in the login library.

Error:Execution failed for task ':core:processReleaseGoogleServices'.
File google-services.json is missing. The Google Services Plugin cannot function without it.

The error is self-explanatory, I need google-services.json in the login module. The point is that the other apps have their own google-services.json too.

Is there a way I can add a dummy google-services.json in the Login module and then override it in each app with the real one?

like image 326
Paolo Rotolo Avatar asked Jan 28 '17 19:01

Paolo Rotolo


People also ask

Where to put the google-services JSON file?

The google-services. json file is generally placed in the app/ directory (at the root of the Android Studio app module).

How do you add google-services JSON file in react native?

Go to the Firebase Console, create a new application OR select an existing project. Go to Project Settings and under the General tab. Click on Your Apps , add an Android application, and download your google-services. json file – you need to put this in the root of your projects android directory.


1 Answers

You can't have a google-services.json file in a library. You have to add the dependencies needed, and it is enough to compile to library.

Instead in the projects which will use the library, you have to add the plugin and the google-services.json file.

To do it in your library, in the build.gradle you have to remove the line

//apply plugin: 'com.google.gms.google-services'
like image 145
Gabriele Mariotti Avatar answered Sep 28 '22 02:09

Gabriele Mariotti