https://kotlinlang.org
Join Slack
Has anyone devised a good way to add a dynamic auth header to a multiplatform apollo client? Seems ...
c

clark

over 4 years ago
Has anyone devised a good way to add a dynamic auth header to a multiplatform apollo client? Seems like the recommended OkHttp interceptor would only work on Android, right?
c
m
+2
  • 4
  • 41
  • 301
I updated to the latest iguana and I'm getting delightful error messages that I can't seem to resolv...
c

czuckie

about 2 years ago
I updated to the latest iguana and I'm getting delightful error messages that I can't seem to resolve: 🧵
c
e
+2
  • 4
  • 16
  • 300
I have a complex multi-module Kotlin multi-platform project. It has a `buildSrc` module loading seve...
n

Norbi

about 2 years ago
I have a complex multi-module Kotlin multi-platform project. It has a
buildSrc
module loading several common Gradle plugins, used by precompiled script plugins:
// buildSrc/build.gradle.kts

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
    ...
}
The project had no Android support, but now I'd like add the Android plugin as well to one of the sub-modules. It seems that I have to add it to
buildSrc
as well, otherwise I get the error (which seems to be a Gradle classloading conflict):
Unable to load class 'com.android.build.gradle.api.BaseVariant'.
So I added it to
buildSrc
as well:
// buildSrc/build.gradle.kts

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
    ...
    implementation("com.android.tools.build:gradle:8.1.1")
}
Gradle sync now works in Idea but when I try to compile the project, errors like the following appear:
Cannot locate tasks that match ':kotlinw:kotlinw-remoting-client-ktor:compileJava' as task 'compileJava' not found in project ':kotlinw:kotlinw-remoting-client-ktor'.
Which I don't understand because the given project is a Kotlin-only project, it has no Java sources, and the Android plugin is not applied to it... Do you have any idea what is happening? Thanks.
n
x
  • 2
  • 5
  • 300
I have an arrow Either deserializer that I found in a thread here, that I’ve slightly modified, but ...
s

snowe

over 3 years ago
I have an arrow Either deserializer that I found in a thread here, that I’ve slightly modified, but for some reason it fails if my object has a different class discriminator, even if I specify a specific one just for the deserializer. no clue what’s going on. anyone?
class EitherSerializer<R>(
    private val leftSerializer: KSerializer<PricingError>,
    private val rightSerializer: KSerializer<R>,
) : KSerializer<Either<PricingError, R>> {
    override val descriptor: SerialDescriptor
        get() = rightSerializer.descriptor

    private val errorJson = Json {
        ignoreUnknownKeys = true
        isLenient = true
        encodeDefaults = true
    }

    override fun deserialize(decoder: Decoder): Either<PricingError, R> {
        require(decoder is JsonDecoder) { "only works in JSON format" }
        val element = Either.catch {
            decoder.decodeJsonElement()
        }.mapLeft { PricingError.SerializationError(it.localizedMessage) }
        return when (element) {
            is Either.Left -> element
            is Either.Right -> {
                try {
                    decoder.json.decodeFromJsonElement(rightSerializer, element.value).right()
                } catch (_: SerializationException) {
                    errorJson.decodeFromJsonElement(leftSerializer, element.value).left() // fails here with error in thread
                }
            }
        }
    }

    override fun serialize(encoder: Encoder, value: Either<PricingError, R>) {
        TODO("Not yet implemented")
    }
}
s
d
e
  • 3
  • 29
  • 300
Hi all, has anyone had trouble with `@Composable` interface methods getting `AbstractMethodError` is...
l

Lauren Yew

over 3 years ago
Hi all, has anyone had trouble with
@Composable
interface methods getting
AbstractMethodError
issues? I have a simple interface that I'm using with Hilt to pass Compose Theme components back to a library.
import androidx.compose.material.Colors
import androidx.compose.runtime.Composable

interface DevSettingsMaterialTheme {
    @Composable
    fun devSettingsLightColors(): Colors?
...
}

class SampleDevSettingsMaterialTheme : DevSettingsMaterialTheme {
  
    @Composable
    override fun devSettingsLightColors(): Colors? = null // crashes w AbstractMethod
...
}
The library itself was able to implement the interface no problem, and I have tested with one app and it works fine, but another sample app where I'm using the same library (same gradle plugin version 7.1.0 + kotlin version 1.6.10, Java version 11, compose version 1.1.1), when I run the app and try to use the library feature, I get the error
java.lang.AbstractMethodError: abstract method "androidx.compose.material.Colors com...android.devsettings.di.DevSettingsMaterialTheme.devSettingsLightColors(androidx.compose.runtime.Composer, int)"
. Any ideas on how I can work around this? Thanks!
l
a
  • 2
  • 2
  • 300
Anyone achieved to inject a ViewModel on a compose Preview? Does it even make sense? What's the best...
n

Nacho Ruiz Martin

over 4 years ago
Anyone achieved to inject a ViewModel on a compose Preview? Does it even make sense? What's the best approach to be able to preview a screen?
n
a
  • 2
  • 2
  • 300
After migrating to ktlint 1.2.1 I am getting an error when attempting to suppress _property_naming_ ...
l

Lex Luthor

over 1 year ago
After migrating to ktlint 1.2.1 I am getting an error when attempting to suppress _property_naming_ in the following file: ExternalModel.kt
@Suppress("ktlint:standard:property-naming")
interface ExternalModel {
    val sys_id: String?
    val table_name: String
}
$ ./gradlew ktlintFormat
...
* What went wrong:
Execution failed for task ':runKtlintCheckOverMainSourceSet'.
> A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.KtLintWorkAction
   > 'void org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt.checkDecompiledText(org.jetbrains.kotlin.com.intellij.psi.PsiElement)'
I am using the following configuration:
Gradle 8.6
Amazon Corretto 17.0.10-amzn
Ktlint Gradle 12.1.0
ktlint 1.2.1
Anyone come across this?
l
a
p
  • 3
  • 5
  • 299
How can i import Classes like NWPathMonitor in iosmain for network observation
f

Farhazul Mullick

over 1 year ago
How can i import Classes like NWPathMonitor in iosmain for network observation
f
m
e
  • 3
  • 5
  • 299
Coming from C++/Qt/QML land, just got started on Kotlin/Compose about 2 weeks ago. So far so good, I...
f

Franck

about 2 years ago
Coming from C++/Qt/QML land, just got started on Kotlin/Compose about 2 weeks ago. So far so good, I believe this is a really nice and powerful library. Most difficult part to understand for me is how do you expose some of your business logic to the UI? Say I have a service for making grpc calls. How do i access the services from my Composable functions? Do I need to create some sort of Service Locator? Use Dependency injection? What is the right pattern to use for exposing backend services or adapters to the frontend?
f
c
+3
  • 5
  • 18
  • 299
Hi, How can we update a singleton component if we have any param changes to be applied to any given ...
p

Preetham Ivan Dsouza

about 3 years ago
Hi, How can we update a singleton component if we have any param changes to be applied to any given @provides method using Hilt dependency injection? Since Singleton components are initialised initially itself and if we have to update any keys to the
certificatePinner
etc (if we are setting keys dynamically and not locally) how do we achieve the same with Hilt? Ref: Similar use case to this issue
p
d
  • 2
  • 1
  • 299
Previous235236237Next

kotlinlang

A modern programming language that makes developers happier.

Powered by