skip to Main Content

Is there a way to load google-services.json from a REST API rather than copying it to the project?

2

Answers


  1. This is not possible because the initialisation of Google libraries is internal and it expects to read client information from this file.

    Login or Signup to reply.
  2. According to the official documentation regarding The Google Services Gradle Plugin:

    The google-services plugin has two main functions:

    1. Process the google-services.json file and produce Android resources that can be used in your application’s code.
    2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search