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

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

问题描述

我有多个 Android 应用程序,它们都包含一个自定义库.这个库是应用程序的核心,每个应用程序只包含一个主 Activity,从库中扩展一个 Activity 来决定特定应用程序的风格.

我现在想在整个应用程序中包含 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天全站免登陆