简体   繁体   English

如果我的 android 本机应用程序中有多个模块,如何连接 firebase

[英]How to connect firebase if I have multiple modules in my android native app

I am working on my Final year project, which is an android native app, using Kotlin.我正在使用 Kotlin 进行我的最后一年项目,这是一个 android 本机应用程序。 my question is how to connect firebase with all modules do I need to copy the JSON file in every module as well as add all the required dependencies in every module ie auth module, resources module, etc. I am confused about this I think this would be really hard to maintain.我的问题是如何将 firebase 与所有模块连接我是否需要在每个模块中复制 JSON 文件以及在每个模块中添加所有必需的依赖项,即身份验证模块、资源模块等。我对此感到困惑我认为这会真的很难维护。

Please give me some best suggestions on how to handle multi-module project effectively请给我一些关于如何有效处理多模块项目的最佳建议

"

No need to add dependency in each and every module, let's just keep all the firebase related handling in separate firebase module and add that module in main app module.无需在每个模块中添加依赖项,让我们将所有与 firebase 相关的处理保留在单独的firebase模块中,并将该模块添加到主app模块中。 From app module you can simply call the implementation in firebase module and make it work.app模块中,您可以简单地调用firebase模块中的实现并使其工作。

PS: please make sure the project you are gonna develop has to be multi-module. PS:请确保您要开发的项目必须是多模块的。 Not every app needs to develop on multi-module approach IMO.并非每个应用程序都需要在多模块方法 IMO 上开发。

As you are already having a multi module Android app, so you definitely must be having a base\/core module on which all the other modules must be depending on.由于您已经拥有一个多模块 Android 应用程序,因此您肯定必须拥有一个基础\/核心模块,所有其他模块都必须依赖于该模块。

There are 2 things you can do你可以做两件事

  1. Add a common wrapper class where are firebase related code is present into your base module and then access the same across different modules.添加一个通用的包装类,其中与 firebase 相关的代码存在于您的基本模块中,然后在不同的模块中访问相同的代码。<\/li>
  2. Use api<\/em> instead of implementation<\/em> in your build.gradle file while adding firebase dependancy.在添加 firebase 依赖时,在 build.gradle 文件中使用api<\/em>而不是implementation<\/em> 。 This way you will get access to Firebase across all the modules which depend on your base\/common module.这样,您将可以跨所有依赖于您的基本\/通用模块的模块访问 Firebase。<\/li><\/ol>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我将Firebase与Android Gradle连接时,我遇到了这个问题 - When I connect Firebase with my Android Gradle I have this problem 我试图将我的 Android 应用程序连接到 google firebase,但它显示一个错误 - I tried to connect my Android app to google firebase but it displays an error 如何在我的 android 应用程序中拥有多个主题? - How to have multiple theme in my android app? 如何构建我的react-native JS代码以在同一项目中具有多个android应用程序? - How do I structure my react-native JS code to have multiple android apps in the same project? 如何使用 firebase 连接 webapp 和 android 应用程序? - How do I connect a webapp and an android app with firebase? 如何将设备连接到Android Firebase数据库 - How can I connect a device to my Android firebase database 如何将我的数据库连接到我的 android 应用程序 - How can i connect my database to my android app 我是否必须在 Android Studio 和 Firebase 控制台 Z2567A5EC3005EB7AC2CZ948 中将我的应用程序链接到 Firebase? - Do I have to link my app to Firebase in both Android Studio and Firebase Console web? 我的Android应用程序中可以有多个getIntent()方法吗? - Can i have Multiple getIntent() methods in my android App? Android Studio中的多个本机模块 - Multiple Native Modules in Android Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM