Search code examples

Google services json file for github actions?

I am currently working on a android project and I use github action to test the project. But whenever it build it ends up with an error for not finding the google-services.json file.

The error generated is as follows

File google-services.json is missing. The Google Services Plugin cannot function without it.

Now, I don't want to commit or upload the google-services.json file on the github. So, Is there any other way to solve this?


  • Well... I have found the solution but in case if anyone needs I am explaining here.

    We can store the content of google-sevices.json in Environment variable (aka Secrets in github). Actually github uses linux based cli so we have to execute some command on the cli using github actions.

    There will be two steps ...

    • Firstly create the google-services.json file in base64
    - name: Create file
      run: cat /home/runner/work/<Project-Name>/<Project-Name>/app/google-services.json | base64
    • Then put data in the file (basically this fetch data from github secrets and put the data in json file before building the application)
    - name: Putting data
        DATA: ${{ secrets.GOOGLE_SERVICES_JSON }}
      run: echo $DATA > /home/runner/work/<Project-Name>/<Project-Name>/app/google-services.json
    • Then define the content of google-services.json file in the github secrets via: Setting > Secrets > New Repository Secret using name GOOGLE_SERVICES_JSON

    Both of these commands should be placed before the gradle build command in gradle.yml

    By doing this your google-services.json file will be created and has data also so the app will build successfully.