GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
1.16k stars 156 forks source link

NoClassDefFound: Ldev/gitlive/firebase/Firebase #606

Open lhalegria opened 2 months ago

lhalegria commented 2 months ago

I'm trying to develop a multiplatform library using the firebase-analytics but I'm getting stuck on the firebase initialization, in both android/ios specific plarforms.

I wonder whether that's not any documentation or a sample for the same or similar purpose. I looked up around to find something but no success.

Below my implementation:

/**
 * Analytics SDK entry point.
 */
object Analytics {

    /**
     * Start the Analytics SDK.
     */
    fun initialize(platformInitializer: Platform) {
        platformInitializer.initializeFirebase()
    }
}
interface Platform {
    fun initializeFirebase()
}
import android.content.Context
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.initialize

class AndroidPlatform(private val context: Context) : Platform {
    override fun initializeFirebase() {
        Firebase.initialize(context)
    }
}
import dev.gitlive.firebase.Firebase
import platform.UIKit.UIApplication
import dev.gitlive.firebase.initialize

class iOSPlatform(private val application: UIApplication) : Platform {
    override fun initializeFirebase() {
        Firebase.initialize(application)
    }
}

And in the application onCreate:

class App : Application() {

    override fun onCreate() {
        super.onCreate()
        Analytics.initialize(AndroidPlatform(this))
    }
}

I am receiving a java.lang.NoClassDefFoundError: Failed resolution of: Ldev/gitlive/firebase/Firebase; and I am not sure what I am doing wrong.

ps.: I've created this on discussions previously.

Daeda88 commented 2 months ago

Can you share your (relevant) gradle setup?