firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

Facing issue while trying to read collection from firestore

Open ahmad244221 opened this issue 1 year ago • 4 comments
trafficstars

I am facing ClassNotFoundException while reading collection. I have added all the needed dependencies in gradle file. I did the signin process with custom token.

Caused by: java.lang.ClassNotFoundException: Didn't find class "dev.gitlive.firebase.DecodersKt"

Below is the shared module gradle dependencies

val commonMain by getting { dependencies { implementation(libs.kotlinx.coroutines.core) implementation(libs.ktor.client.core) implementation(libs.ktor.client.content.negotiation) implementation(libs.ktor.serialization.kotlinx.json) implementation(libs.ktor.client.logging) implementation(libs.koin.core) implementation(libs.sql.coroutines.extensions) implementation(libs.firebase.firestore) implementation(libs.firebase.common) implementation(libs.kotlinx.serialization.json) implementation(libs.firebase.auth) } }

These are android module denpencies.

dependencies { implementation(projects.shared) implementation(libs.compose.ui) implementation(libs.compose.ui.tooling.preview) implementation(libs.compose.material3) implementation(libs.androidx.activity.compose) implementation(libs.androidx.appcompat) implementation(libs.androidx.constraintlayout) implementation(libs.material) implementation(libs.androidx.lifecycle.livedata.ktx) implementation(libs.androidx.lifecycle.viewmodel.ktx) implementation(libs.androidx.navigation.fragment.ktx) implementation(libs.androidx.navigation.ui.ktx) debugImplementation(libs.compose.ui.tooling) implementation(libs.koin.android) implementation(platform(libs.google.firebase.bom)) implementation(libs.firebase.common.ktx) implementation(libs.google.firebase.common) }

Please suggest if anyone faced this issue or some workaround to fix this issue.

ahmad244221 avatar Aug 26 '24 16:08 ahmad244221

@Daeda88 any clue on this?

nbransby avatar Aug 27 '24 00:08 nbransby

Below are lines of code I am trying to read collection after calling signInWithCustomToken() -

`1. val tokenResponse = auth.signInWithCustomToken(customtoken) val response = firestore.collection("collectionPath") .document("documentPath").get().data<MyDataClass>(MyDataClass.serializer()) println("response... $response")

  1. val tokenResponse = auth.signInWithCustomToken(customtoken) val response = firestore.collection("collectionPath") .document("documentPath").get().data<MyDataClass>(ServerTimestampBehavior.ESTIMATE) println("response... $response")`

In both cases I am getting same exception - Caused by: java.lang.ClassNotFoundException: Didn't find class "dev.gitlive.firebase.DecodersKt"

ahmad244221 avatar Aug 27 '24 05:08 ahmad244221

Please let me know if any more input needed here. Is this DecodersKT an internal class and not exposed publicly. Please suggest for any alternate solution to overcome this issue.

ahmad244221 avatar Aug 28 '24 09:08 ahmad244221

DecodersKt has been moved to dev.gitlive.firebase.internal, so the fact your logging is trying to get it from dev.gitlive.firebase indicates to me that something is wrong in your setup. Are you sure you use a consistent version of the sdk for all of your modules?

Daeda88 avatar Aug 29 '24 07:08 Daeda88