fweigl
fweigl

Reputation: 22028

Load google-services.json from local file system

The google-services.json file used by the Firebase Android plugin is usually put in the app's module folder.

What I do want to do instead is put this file somewhere on the filesystem completely outside the project folder and let gradle / the Firebase plugin read it from there.

I thought about putting it's location in the local.properties and somehow 'tell' the Firebase plugin to get the location of the google-services.json from there. How can I achieve this?

Upvotes: 0

Views: 528

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 138869

According to offical documentation, the google-services.json file is generally placed in the app/ directory (at the root of the Android Studio app module). As of version 2.2.0 the plugin supports build type and product flavor specific JSON files. All of the following directory structures are valid:

// dogfood and release are build types.
app/
    google-services.json
    src/dogfood/google-services.json
    src/release/google-services.json
    ...

Note: Providing a google-services.json file in the release directory allows you to maintain a separate Firebase project for your production APKs. When product flavors are in use these more complicated directory structures are also valid.

// free and paid are product flavors.
app/
    google-services.json
    src/dogfood/paid/google-services.json
    src/release/free/google-services.json
    ...

As a conclusion, you cannot add google-services.json file outside your project.

Hope it helps.

Upvotes: 2

Related Questions