Following the guide on setting up Google Analytics in an Android app (https://developers.google.com/analytics/devguides/collection/android/v4/) I am left wondering if this google-services.json file can safely be committed into source code versioning and pushed to a public GitHub repository or if this file may contain credentials or secrets.
I cannot find a definite answer elsewhere, but I can see that sample apps both commit the file (https://github.com/google/climb-tracker/blob/master/mobile/google-services.json) and others have added the file to their .gitignore.
Willie Chalmers III points to "Is google-services. json safe from hackers?", and adds: Yes, that API key isn't a server API key which should never be public, so it's fine if your google-services. json is visible by others.
The way that the Google plugin is set up, it will be really hard for you to hide the content of the google-services. json file. The only viable way would be to re-implement yourself what the plugin already does for you, which I wouldn't recommend.
The google-services. json file created in this doc is used within your app to connect to firebase and facilitate Android Push Notifications and is normally labelled google-services.
The google-services. json file is generally placed in the app/ directory (at the root of the Android Studio app module).
From this post it seems there's no real reason to keep this file safe. It's data will be in the APK anyway.
Yes. At least the api_key
stuff should be kept confidential.
One way to put google-services.json
into your public repository and still keep it confidential is to use BlackBox.
In your app level build.gradle
put a copy task in for example defaultConfig
like this:
defaultConfig { ... ... copy { from "../secret/" into "." include "*.json" } }
which will copy the file from your secret/
folder to the right spot.
Now, to build your app you'll have to run blackbox_edit_start google-services.json.gpg
the first time you check out your repo, and after that you're good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With