android - 如何将 firebase 导入 app 模块以外的模块?

标签 android firebase gradle module multi-module

我想制作一个带有单独数据模块的多模块应用程序。我可以在普通的 kotlin 模块中导入 firebase 吗?如果不能,我应该如何修改我的数据模块才能将 firebase 导入其中?

buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.google.gms:google-services:4.3.2'
  }
}
plugins {
  id "org.jetbrains.kotlin.jvm"
}
dependencies {
  def moduleDependencies = rootProject.ext.remoteDependencies
  def moduleTestDependencies = rootProject.ext.remoteTestDependencies

  implementation moduleDependencies.firestore
  implementation moduleDependencies.firestoreKtx
}
compileKotlin {
  kotlinOptions.jvmTarget = "1.8"
}
apply plugin: 'com.google.gms.google-services'

这是我的数据模块中的当前构建文件。目前我能够同步和构建,但我无法在模块中导入 firebase 库。

编辑:问题是我想在 app 模块以外的模块中使用 firestore,但是当我在数据模块中添加它的依赖项时,我无法使用 Firestore(因为未解析的引用)

最佳答案

问题是我试图在纯 kotlin 库中使用 firestore,以解决我必须添加的问题: apply plugin: 'com.android.library', apply plugin: 'kotlin-android', 和一个 android block 到 gradle 文件模块的。 (基本上我必须将我的 kotlin 库转换为 android 库)

关于android - 如何将 firebase 导入 app 模块以外的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59504272/

相关文章:

Android 11 权限问题

c# - Xamarin - Java.Lang.Thread 与 System.Threading.Thread - 使用哪一个?

android - 如何在 Firebase 云消息传递 (FCM) 中使用深度链接

gradle - 忽略 Spotless 生成的资源

netbeans - 如何在NetBeans上使用Gradle启动Spring-MVC应用程序

java - 以编程方式隐藏微调器列表

返回时 Android 刷新 Activity

java - 我可以使用 Firestore 检索不同集合中具有相同名称的相同子集合的文档吗?

c# - Xamarin 是否支持 Firebase Cloud Firestore?

java - 如何使用 gradle 构建的项目执行命令行工具?