How can I import Firebase into a module other than the app module?


Patrick

I want to make a multi-module application with separate data modules. Can I import Firebase in a pure Kotlin module? If not, how should I modify the Data module to import Firebase into it?

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'

This is my current build file in the data module. Currently, I can sync and build, but cannot import the Firebase library inside the module.

EDIT: The problem is that I want to use firestore in a module other than the app module, but when I add a dependency to it in the data module, I can't use firestore (due to unresolved references)

Patrick

The problem is that I'm trying to use firestore in a pure Kotlin library to solve the problem that I have to add apply plugin: 'com.android.library', and apply plugin: 'kotlin-android'a block in the gradle file of the module . (basically I have to convert my kotlin library to android library)android

Related


How can I use import if I want to import a module as a string?

shadow I have a list of module names in an array. I want to import all these modules from an already imported class. It seems that I cannot use from TestModule __import__(name) How can I do this? Here is what I have: import MainModule arr = \ ['Module1', '

How can I use import if I want to import a module as a string?

shadow I have a list of module names in an array. I want to import all these modules from an already imported class. It seems that I cannot use from TestModule __import__(name) How can I do this? Here is what I have: import MainModule arr = \ ['Module1', '

How can I import my App module into the MyAppUITests file?

巴特米米 (BartłomiejSemańczyk) Here is my simple test case: import XCTest @testable import MyApp //it doesn't work because of this: class TabBarControllerTests: XCTestCase { override func setUp() { super.setUp() let defaults = NSUserDefaults

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance This is impossibl

React - Firebase module error when I try to import 'firebase/app'

Sklar I'm currently working on a small React project and I'm running into some errors related to the "firebase" module . When I try to import the firebase module, I get the following error: Module not found: cannot resolve 'firebase/app' in 'C:project_name\nod

How can I use import if I want to import a module as a string?

shadow I have a list of module names in an array. I want to import all these modules from an already imported class. It seems that I cannot use from TestModule __import__(name) How can I do this? Here is what I have: import MainModule arr = \ ['Module1', '

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance This is impossibl

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance This is impossibl

React - Firebase module error when I try to import 'firebase/app'

Sklar I'm currently working on a small React project and I'm running into some errors related to the "firebase" module . When I try to import the firebase module, I get the following error: Module not found: cannot resolve 'firebase/app' in 'C:project_name\nod

How can I use import if I want to import a module as a string?

shadow I have a list of module names in an array. I want to import all these modules from an already imported class. It seems that I cannot use from TestModule __import__(name) How can I do this? Here is what I have: import MainModule arr = \ ['Module1', '

How can I import my App module into the MyAppUITests file?

巴特米米 (BartłomiejSemańczyk) Here is my simple test case: import XCTest @testable import MyApp //it doesn't work Because of this: class TabBarControllerTests: XCTestCase { override func setUp() { super.setUp() let defaults = NSUserDefaults

How to use FormsModule in modules other than app module?

Shubagit Halder I am trying to add FormsModule in myform.module.ts but it is not working and showing me this error. error NG8003: No directive found with exportAs 'ngForm' What I have done so far: myform.module.ts This is the HTML file. When I do the same on

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance it's out of the q

React - Firebase module error when I try to import 'firebase/app'

Sklar I'm currently working on a small React project and I'm running into some errors related to the "firebase" module . When I try to import the firebase module, I get the following error: Module not found: cannot resolve 'firebase/app' in 'C:project_name\nod

How can I use import if I want to import a module as a string?

shadow I have a list of module names in an array. I want to import all these modules from an already imported class. It seems that I cannot use from TestModule __import__(name) How can I do this? Here is what I have: import MainModule arr = \ ['Module1', '

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance it's out of the q

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance it's out of the q

React - Firebase module error when I try to import 'firebase/app'

Sklar I'm currently working on a small React project and I'm running into some errors related to the "firebase" module . When I try to import the firebase module, I get the following error: Module not found: cannot resolve 'firebase/app' in 'C:project_name\nod

React - Firebase module error when I try to import 'firebase/app'

Sklar I'm currently working on a small React project and I'm running into some errors related to the "firebase" module . When I try to import the firebase module, I get the following error: Module not found: cannot resolve 'firebase/app' in 'C:project_name\nod

Can I import ES modules from other <script type="module">?

pp I want to import from another script tag. <script type="module"> export default "str" </script> <script type="module"> import foo from "????" console.log(foo) // str </script> What should I write in "???"? certain performance it's out of the q

How can I import my App module into the MyAppUITests file?

巴特米米 (BartłomiejSemańczyk) Here is my simple test case: import XCTest @testable import MyApp //it doesn't work Because of this: class TabBarControllerTests: XCTestCase { override func setUp() { super.setUp() let defaults = NSUserDefaults