https://kotlinlang.org
Join Slack
What is this error mean? ```Unresolved reference: implementation``` My build.gradle.kts file <https:...
m

MisileLab

about 4 years ago
What is this error mean?
Unresolved reference: implementation
My build.gradle.kts file https://pastebin.com/EAcCPBff
m
r
n
  • 3
  • 6
  • 1146
is there a way to globally exclude a directory? we have some generated code checked in (yes… we know...
e

Eric

over 3 years ago
is there a way to globally exclude a directory? we have some generated code checked in (yes… we know). And want to exclude that directory from contributing to score and from being formatted automatically.
e
e
+2
  • 4
  • 6
  • 1145
what may the cause of "Unresolved reference: Composable" in iosMain? androidx.compose.runtime.Compos...
r

Romão

over 2 years ago
what may the cause of "Unresolved reference: Composable" in iosMain? androidx.compose.runtime.Compose is imported but the compiler outputs error
r
j
+3
  • 5
  • 76
  • 1144
Hi folks, How do I run a custom gradle task that only runs after the build tasks completes in a KMM ...
k

Kwabena Berko

about 3 years ago
Hi folks, How do I run a custom gradle task that only runs after the build tasks completes in a KMM project?
tasks.register("copySomething", Copy::class) {
   println("How Do I Run This Task After Build Completes?")
}
k
j
m
  • 3
  • 15
  • 1142
Hello, what is the best “Compose way” to repeat an animation just a specific number of times? For in...
s

svenjacobs

about 3 years ago
Hello, what is the best “Compose way” to repeat an animation just a specific number of times? For instance I want to highlight a specific item on my screen by shortly flashing the background. Would the following (pseudo) code be okay or are there any better solutions?
enum class BackgroundState { Normal, Highlighted }

@Composable
fun Item() {
    var backgroundState by remember { mutableStateOf(BackgroundState.Normal) }
    val backgroundColor by animateColorAsState(
        targetValue = when (backgroundState) {
            BackgroundState.Normal -> Color.Transparent
            BackgroundState.Highlighted -> Color.Yellow
        },
        animationSpec = tween(),
    )

    LaunchedEffect(Unit) {
        delay(250)
        backgroundState = BackgroundState.Highlighted
        delay(250)
        backgroundState = BackgroundState.Normal
        delay(250)
        backgroundState = BackgroundState.Highlighted
        delay(250)
        backgroundState = BackgroundState.Normal
    }

    Box(modifier = Modifier.background(backgroundColor)) {
        Text("Hello World")
    }
}
Thanks for your help!
s
y
+3
  • 5
  • 13
  • 1136
What is the best practice to refresh OAuth access tokens using a refresh token in OkHttp? I have the...
l

Lukasz Kalnik

about 3 years ago
What is the best practice to refresh OAuth access tokens using a refresh token in OkHttp? I have the following setup, but it's failing in case of parallel calls. The
synchronized(lock)
doesn't seem to prevent the second call to try to refresh the token as well.
val okHttpClient = OkHttpClient.Builder()
    .addInterceptor(AccessTokenInterceptor(oAuthRepository))
    .authenticator(RefreshTokenAuthenticator(oAuthRepository))
    .build()

val lock = Any()

private class AccessTokenInterceptor(
    private val oAuthRepository: OAuthRepository
) : Interceptor {

    override fun intercept(chain: Chain): Response {
        synchronized(lock) {
            val token = oAuthRepository.accessToken

            val request = chain.request().newBuilder().apply {
                if (token != null) header("Authorization", "Bearer $token")
            }.build()
            return chain.proceed(request)
        }
    }
}

private class RefreshTokenAuthenticator(
    private val oAuthRepository: OAuthRepository
) : Authenticator {

    override fun authenticate(route: Route?, response: Response): Request? {
        if (response.responseCount >= 2) return null

        synchronized(lock) {
            return runBlocking {
                oAuthRepository.refreshTokens().map {
                    oAuthRepository.accessToken
                }
            }.fold(
                ifLeft = { null },
                ifRight = {
                    it?.let { token ->
                        response.request.newBuilder()
                            .header("Authorization", "Bearer $token")
                            .build()
                    }
                }
            )
        }
    }
}
l
y
+2
  • 4
  • 8
  • 1135
How do we flatten a JSON with nested elements into a single class? E.g. I’ve to following OSM data t...
b

BollywoodVillain

almost 5 years ago
How do we flatten a JSON with nested elements into a single class? E.g. I’ve to following OSM data that I need to have in just one class, without creating a subclass for `tags`:
{
      "type": "node",
      "id": 66917229,
      "lat": 52.5167295,
      "lon": 13.3797732,
      "tags": {
        "addr:city": "Berlin",
        "addr:housenumber": "4a",
        "addr:postcode": "10117",
        "addr:street": "Pariser Platz",
        "amenity": "cafe",
        "brand": "Starbucks",
        "name": "Starbucks",
        "website": "<https://www.starbucks.de/store-locator/store/2099/pariser-platz-pariser-platz-4-a-berlin-be-10117-de>",
        "wheelchair": "yes",
        "wifi": "free"
      }
    }
I am using custom Serializer but I’m a bit lost on how to unwrap the nested values in the
deserialize
function for the nested tags element. Any help is highly appreciated.
b
r
v
  • 3
  • 8
  • 1132
&gt; 'capitalize(): String' is deprecated. Use replaceFirstChar instead what is the thinking here? `...
j

Jonathan Ellis

over 3 years ago
'capitalize(): String' is deprecated. Use replaceFirstChar instead
what is the thinking here?
replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
is a lot clunkier
😕 1
j
m
+3
  • 5
  • 18
  • 1131
Is there any example on how to use gradle version catalog toml where the BOM of spring boot is defin...
h

Humphrey

over 2 years ago
Is there any example on how to use gradle version catalog toml where the BOM of spring boot is defined as platform so I don’t need to specify any version of the dependencies that is already provided by that BOM? And how do I override/pin just one version let’s say for the H2 database (com.h2databsse) to an older version? And add additional dependencies that are not there in the spring boot BOM?
h
v
c
  • 3
  • 8
  • 1129
is there a way to get more verbose errors out of the kotlin compiler? When i use `gradlew classes`,...
v

Victor Ng

about 2 years ago
is there a way to get more verbose errors out of the kotlin compiler? When i use
gradlew classes
, I frequently get nothing useful from the compiler>
❯ ./gradlew classes

> Task :kaptGenerateStubsKotlin FAILED
e: Could not load module <Error module>

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':kaptGenerateStubsKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to <https://docs.gradle.org/8.2.1/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.

BUILD FAILED in 874ms
3 actionable tasks: 1 executed, 2 up-to-date
not kotlin but kotlin colored 0
v
h
r
  • 3
  • 3
  • 1128
Previous343536Next

kotlinlang

A modern programming language that makes developers happier.

Powered by