在库中包括Firebase Analytics [英] Include Firebase Analytics in library

查看:57
本文介绍了在库中包括Firebase Analytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个Android应用程序,都包含一个自定义库.该库是应用程序的核心,每个应用程序仅包含一个主要活动,该活动扩展了库中的活动以决定特定应用程序的口味.

我现在想在整个应用程序(包括库)中包括Firebase Analytics,但是我无法确定如何做.每个应用程序的google-services.json文件应该有所不同,但是如果没有包含库的软件包名称的google-services文件,我不能包含google-services插件.

我希望你有个主意.

谢谢!

解决方案

您应该添加google-services.json文件,并将google-services插件应用于您的 app 模块,而不是 图书馆项目.

该插件生成的大多数资源都是动态使用的,并且对于库的编译不是必需的.但是,如果该库确实使用了其中一种资源(因此如果没有它就无法编译),则该库可以在其自己的strings.xml文件中包含一个占位符资源,该资源最终将被正确配置的应用覆盖.

I have multiple Android apps that all include a custom library. This library is the core of the apps, and each app just contains a main activity extending an activity from the library to decide which flavour the specific app has.

I now want to include Firebase Analytics in the whole app, including the library, but I cannot wrap my head around how to. The google-services.json file should be different for each app, but I can not include the google-services plugin without a google-services file containing the library's package name.

I hope you have som ideas.

Thank you!

解决方案

You should add the google-services.json file and apply the google-services plugin to your app module, not the library project.

Most of the resources generated by the plugin are used dynamically and won't be necessary for the library to compile. However, if the library does use one of those resources explicitly (and therefore can't compile without it), the library can include a placeholder resource in its own strings.xml file which will eventually be overridden by the properly configured app.

这篇关于在库中包括Firebase Analytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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