如何使用Google Services Gradle插件在Circle CI上测试android应用 [英] How to test android application on Circle CI with Google Services Gradle Plugin

查看:74
本文介绍了如何使用Google Services Gradle插件在Circle CI上测试android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Services Gradle插件(Firebase需要此应用)开发android应用,并且该插件需要google-services.json。

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

我认为json文件不应该在git的控制下,因为它具有一些应该隐藏的值(例如api_key),但是Circle CI需要一个。

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.

如果google-services.json可以查找环境变量,则此问题可以解决。(值隐藏在git存储库中,Circle CI可以从环境变量中获取值)。

但是,我可以找不到从google-services.json查找环境变量的机制。

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.

我有三个问题。

1)真的应该从VCS中忽略google-services.json吗?

2)Google Services Gradle插件是否具有从google-services.json查找环境变量的机制?

3)还有其他方法可以从Circle CI引用google-services.json吗?

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)是的,它应该-它包含敏感信息,例如您的API密钥。

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

2)我不这么认为

3 )您可以使用与> https://circleci.com/docs/2.0/google类似的方法-auth /

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


  • 将您的google-services.json编码为base64。确保从编码的字符串中删除所有空格

  • 将其放入Circle CI的项目设置中的环境变量(我将其命名为GOOGLE_SERVICES)

  • 在circle.yml文件中将此变量解码为您应用目录中的google-services.json文件。就我而言,我使用

  • 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

这篇关于如何使用Google Services Gradle插件在Circle CI上测试android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆