niboshiporipori
niboshiporipori

Reputation: 83

How to test android application on Circle CI with Google Services Gradle Plugin

I'm developing android application with Google Services Gradle Plugin(It is needed from Firebase), and the plugin needs google-services.json.

I think the json file should not be under the control of git because it have some values that should be concealed(ex. api_key), but Circle CI needs the one.

If google-services.json can look up environment variables, the problem can solve.(values are concealed on git repository and Circle CI can get values from environment variables).
But, I can't find mechanism of look up environment variables from google-services.json.

I have three questions.

1) Should google-services.json really be ignored from VCS?
2) Does Google Services Gradle Plugin have the mechanism of look up environment variables from google-services.json?
3) Is there other ways of refer google-services.json from Circle CI?

Upvotes: 7

Views: 1078

Answers (1)

Lukáš Kutner
Lukáš Kutner

Reputation: 306

1) Yes, it should - it contains sensitive information like your API key.

2) I don't think so

3) You can use similar aproach as in https://circleci.com/docs/2.0/google-auth/

  • encode your google-services.json in base64. Make sure to remove any spaces from the encoded string
  • put this to Environment Variable in Project settings of Circle CI ( I named it GOOGLE_SERVICES)
  • in your circle.yml decode this variable to google-services.json file in your app directory. In my case I use

    echo $GOOGLE_SERVICES | base64 --decode > ~/${HOME}/app/google-services.json

Upvotes: 18

Related Questions