I want to make a multi module app with separate Data module. Can I import firebase in a plain kotlin module, and if not, how should I modify my Data module to be able 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 inside my data module. Currently I am able to sync, and build, but I can't import firebase libraries inside the module.
Edit: The problem is that I want to use firestore inside a module other than the app module, but when I add the dependencies for it inside the data module, I can't use Firestore (because of unresolved reference)
The problem was that I tried to use firestore inside a pure kotlin library, to solve the problem I had to add:
apply plugin: 'com.android.library'
, and apply plugin: 'kotlin-android'
, and an android
block to the gradle file of the module. (Basically I had to convert my kotlin library to an android library)