Issue
Is there a way to load google-services.json from an API rather than copying it to the project?
Solution
According to the official documentation regarding href="https://developers.google.com/android/guides/google-services-plugin" rel="nofollow noreferrer">The Google Services Gradle Plugin:
The
google-services
plugin has two main functions:
- Process the google-services.json file and produce Android resources that can be used in your application's code.
- Add dependencies for basic libraries required for the services you have enabled. This step requires that you apply the Google Services Gradle plugin in your app/build.gradle file, like so: apply plugin: 'com.google.gms.google-services'
And to answer your question:
Is there a way to load google-services.json from an API rather than copying it to the project?
No, you cannot. You have to explicitly add the file to the project's app
directory. Alternatively, you can use product flavors when you have to use more complicated directory structures:
// free and paid are product flavors.
app/
google-services.json
src/dogfood/paid/google-services.json
src/release/free/google-services.json
Answered By - Alex Mamo
Answer Checked By - David Goodson (JavaFixing Volunteer)