agrevster / pocketbase-kotlin

A multi-platform Kotlin SDK for Pocketbase.
https://agrevster.github.io/pocketbase-kotlin/
MIT License
24 stars 6 forks source link

Android support? #12

Open SamuelMarks opened 1 month ago

SamuelMarks commented 1 month ago

I assume you have it already! - Just not on this table https://agrevster.github.io/pocketbase-kotlin/#support

agrevster commented 1 month ago

I am not at all familiar with Android development. I have JVM as a target, is there something else I need to do to add android?

SamuelMarks commented 1 month ago

Hmm let me try. Adding to my kotlin.sourceSets of build.gradle.kts:

androidMain.dependencies {
    implementation(libs.ktor.client.okhttp)
    implementation(libs.ktor.client.android)
    implementation(libs.ktor.serialization.kotlinx.json)
}

commonMain.dependencies {
    implementation(libs.coil.network.ktor3)
    implementation(libs.ktor.client.core)
    implementation(libs.kotlinx.coroutines.core)
    implementation(libs.ktor.serialization.kotlinx.json)
    implementation(libs.ktor.client.content.negotiation)
    implementation("io.github.agrevster:pocketbase-kotlin:2.6.3")
}

But getting this error:

java.lang.NoClassDefFoundError: Failed resolution of: Lio/ktor/client/plugins/contentnegotiation/ContentNegotiation;
                                                                                                        at io.github.agrevster.pocketbaseKotlin.PocketbaseClient.httpClient$lambda$3(PocketbaseClient.kt:95)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.PocketbaseClient.$r8$lambda$35QVJFy4Gam8I0rsxXs0bQWumTk(Unknown Source:0)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.PocketbaseClient$$ExternalSyntheticLambda3.invoke(D8$$SyntheticClass:0)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.Module_cioKt.httpClient$lambda$1(Module.cio.kt:7)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.Module_cioKt.$r8$lambda$c5sYuqMXPLJmxFVMt1fY_dgx_4k(Unknown Source:0)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.Module_cioKt$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
                                                                                                        at io.ktor.client.HttpClientKt.HttpClient(HttpClient.kt:42)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.Module_cioKt.httpClient(Module.cio.kt:7)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.PocketbaseClient.<init>(PocketbaseClient.kt:94)
                                                                                                        at io.github.agrevster.pocketbaseKotlin.PocketbaseClient.<init>(PocketbaseClient.kt:21)

Which as far AFAIK is from the fully-qualified name:

import androidx.compose.material.Text
import androidx.compose.runtime.Composable

import io.ktor.http.URLProtocol

private val client = io.github.agrevster.pocketbaseKotlin.PocketbaseClient({
    protocol = URLProtocol.HTTP
    host = "localhost"
    port = 8090
})

@Composable
fun ClientContent() {
    Text(client.toString())
}
agrevster commented 3 weeks ago

From what I’ve read JVM target will work for Android. Can you send your versions toml file?

agrevster commented 3 weeks ago

It looks like it might be a problem on your end

Feinate commented 2 minutes ago

So is it working with Android | Kotlin Multiplatform ?