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

孤街浪徒 提交于 2019-12-21 02:28:10

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/39063493/how-to-test-android-application-on-circle-ci-with-google-services-gradle-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!