Hi guys! How are you? I did Jetbrains guide to cre...
# multiplatform
a
Hi guys! How are you? I did Jetbrains guide to create a Compose Multiplatform project, it worked. I want also to integrate to Firebase Firestore, so there is the library https://github.com/GitLiveApp/firebase-kotlin-sdk, which intends to do this bridge to Firebase services for Compose Multiplatform. The automatization from Jetbrains creates a project with only one folder composeApp, and inside of it we have all targets: Android, iOS, Desktop, Web, ... When I add the libraries from https://github.com/GitLiveApp/firebase-kotlin-sdk inside commonMain sourceSet in build.gradle.kts(:composeApp) like below, and sync the project, it's creating the following errors (The full text of the errors in the thread). I'm not understanding yet the reason since the library suppose to work with all targets. Can you help?
Copy code
kotlin {
    @OptIn(ExperimentalWasmDsl::class)
    wasmJs {
        moduleName = "composeApp"
        browser {
            commonWebpackConfig {
                outputFileName = "composeApp.js"
            }
        }
        binaries.executable()
    }
    
    androidTarget {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    
    jvm("desktop")
    
    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
        }
    }
    
    sourceSets {
        val desktopMain by getting
        
        androidMain.dependencies {
            implementation(libs.compose.ui.tooling.preview)
            implementation(libs.androidx.activity.compose)
            implementation(project.dependencies.platform(libs.firebase.bom))
        }
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.ui)
            @OptIn(ExperimentalComposeLibrary::class)
            implementation(compose.components.resources)
            implementation(libs.kotlinx.datetime)
            implementation("dev.gitlive:firebase-firestore:1.10.4")
            implementation("dev.gitlive:firebase-common:1.10.4")
            implementation(libs.kotlinx.serialization.json)
        }
        desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
        }
    }
}
Could not resolve all dependencies for configuration ':composeApp:wasmJsCompileClasspath'.
> Could not resolve dev.gitlive:firebase-firestore:1.10.4.
Required by:
project :composeApp
> No matching variant of dev.gitlive:firebase-firestore:1.10.4 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm', attribute 'org.jetbrains.kotlin.wasm.target' with value 'js'...
Could not resolve all dependencies for configuration 'composeAppwasmJsCompileClasspath'.
Could not resolve dev.gitlivefirebase firestore1.10.4.
Required by: project :composeApp > No matching variant of dev.gitlivefirebase firestore1.10.4 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm', attribute 'org.jetbrains.kotlin.wasm.target' with value 'js' but: - Variant 'debugApiElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library for use during compile-time: - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'debugRuntimeElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library for use during runtime: - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'debugSourcesElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a component for use during runtime: - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosArm64ApiElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library for use during 'kotlin-api': - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosArm64MetadataElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library: - Incompatible because this component declares a component for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosArm64SourcesElements-published' capability dev.gitlivefirebase firestore1.10.4: - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosSimulatorArm64ApiElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library for use during 'kotlin-api': - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosSimulatorArm64MetadataElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library: - Incompatible because this component declares a component for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosSimulatorArm64SourcesElements-published' capability dev.gitlivefirebase firestore1.10.4: - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosX64ApiElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library for use during 'kotlin-api': - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosX64MetadataElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library: - Incompatible because this component declares a component for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'iosX64SourcesElements-published' capability dev.gitlivefirebase firestore1.10.4: - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' - Other compatible attributes: - Doesn't say anything about its target Java environment (preferred optimized for non-jvm) - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js') - Variant 'jsIrApiElements-published' capability dev.gitlivefirebase firestore1.10.4 declares a library for use during 'kotlin-api': - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
c
There is no WASM target in the library.
You can only have Android, iOS, JVM and JS in your common target.
a
Hi Christian. This wasm comes from official automatic template from Jetbrains.
The new version. So this part I didn't change.
It seems it is an error that Firebase library I said is not compatible, I don't know.
c
Yes, remove it or find another library.
a
Hum!!
Thank you Christian, it worked. Sometimes we don't see what is in our screen. : )
👍 1
Hi @Chrimaeon, do you know if I can use Firebase.initialize for Desktop? It said we can't use context from ApplicationScope from Desktop.
It seems is just for Android only, but strange because the lib says it's for every target.
c
looks like jvm is just using the andorid target
Copy code
getByName("jvmMain") {
            kotlin.srcDir("src/androidMain/kotlin")
        }
and there is not “Android Context” on plain JVM. So, no, you cannot use this “constructor” on jvm.
a
Understood, thank you
It's said that they said it's possible to use for all targets.
c
yeah, no. where do you get the context from on your “common” code?
the
Any
parameter is casted to
Context
so it will not be possible to use it for JVM