Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin 1.5 NoSuchMethodError: DurationKt.getMinutes(int) #278

Closed
BenWoodworth opened this issue May 8, 2021 · 8 comments
Closed

Kotlin 1.5 NoSuchMethodError: DurationKt.getMinutes(int) #278

BenWoodworth opened this issue May 8, 2021 · 8 comments

Comments

@BenWoodworth
Copy link
Contributor

I'm using kord-core 0.7.0-M2 and I get this at startup.

Kotlin 1.5 made changes to the duration api

Duration API changes including using a Long value for the internal representation and providing new properties for retrieving a duration as a Long value.

java.lang.NoSuchMethodError: 'double kotlin.time.DurationKt.getMinutes(int)'
        at com.gitlab.kordlib.rest.ratelimit.AbstractRateLimiter.<init>(AbstractRateLimiter.kt:22)
        at com.gitlab.kordlib.rest.ratelimit.ExclusionRequestRateLimiter.<init>(ExclusionRequestRateLimiter.kt:23)
        at com.gitlab.kordlib.rest.ratelimit.ExclusionRequestRateLimiter.<init>(ExclusionRequestRateLimiter.kt:23)
        at com.gitlab.kordlib.core.builder.kord.KordBuilder$handlerBuilder$1.invoke(KordBuilder.kt:70)
        at com.gitlab.kordlib.core.builder.kord.KordBuilder$handlerBuilder$1.invoke(KordBuilder.kt:57)
        at com.gitlab.kordlib.core.builder.kord.KordBuilder.build(KordBuilder.kt:222)
        at com.gitlab.kordlib.core.builder.kord.KordBuilder$build$1.invokeSuspend(KordBuilder.kt)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:188)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:144)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:15)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:90)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:188)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:144)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:15)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:90)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:188)
        at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:144)
        at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:15)
        at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:90)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
        at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
        at Discord_covid_bot_main.<init>(discord-covid-bot.main.kts:313)
@DRSchlaubi
Copy link
Member

DRSchlaubi commented May 8, 2021

This got merged into master no changed are required anymore

This is a bug related to Kotlin 1.5, which I am currently working on. Due to binary changes in the 1.5 stdlib and some dependencies using 1.5 has some funny odities

Schlaubi's stupid guide to use kord 1.5 (Every change you need I found so far)

  • Make sure to use this version kotlin-1.5
  • if you use kordx make sure to force this version to kordx dependencies
    implementation("dev.kord", "kord-core", "kotlin-1.5") {
        version {
            strictly("kotlin-1.5-SNAPSHOT")
        }
    }

@BenWoodworth
Copy link
Contributor Author

Oops I didn't notice the kotlin-1.5 branch. Glad you're on top of it!

@MrPowerGamerBR
Copy link
Contributor

In my case (Kotlin 1.5.10) I needed to use

    api("dev.kord:kord-rest:kotlin-1.5-SNAPSHOT") {
        version {
            strictly("kotlin-1.5-SNAPSHOT")
        }
    }

The version pinning the kotlin-1.5-20210505.195343-2 didn't work for me, the RestClient constructor was always throwing errors related to NoSuchMethodError (however it was a different error unrelated to the one in the issue)

@DRSchlaubi
Copy link
Member

DRSchlaubi commented May 26, 2021

Whoops I forgot updating that you should use the normal snapshot

EDIT: 1.5.10 works with the latest 1.5 snapshots for me
Edit 2: We have a 1.5.10 snapshot now

@pindab0ter
Copy link

pindab0ter commented May 29, 2021

I still couldn't get a working build going and kept getting the NoSuchMethodError for kotlin.time.DurationKt.getMinutes.

Turns out, this doesn't work:

implementation("dev.kord", "kord-core", "kotlin-1.5-SNAPSHOT")

But this does:

implementation("dev.kord", "kord-core", "kotlin-1.5") {
    version {
        strictly("kotlin-1.5-SNAPSHOT")
    }
}

@DRSchlaubi
Copy link
Member

I still couldn't get a working build going and kept getting the NoSuchMethodError for kotlin.time.DurationKt.getMinutes.

Turns out, this doesn't work:

implementation("dev.kord", "kord-core", "kotlin-1.5-SNAPSHOT")

But this does:

implementation("dev.kord", "kord-core", "kotlin-1.5") {
    version {
        strictly("kotlin-1.5-SNAPSHOT")
    }
}

That's why this post exists: #278 (comment)

@pindab0ter
Copy link

Yes, I know. That was the comment that helped me out of the impasse. My comment was meant as a clarification for others running into this problem, which turned out to be a syntax issue.

@HopeBaron
Copy link
Member

Has been merged to 0.7.x re-open if you'd like further discussion use the 0.7.x-SNAPSHOT artifact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants