https://kotlinlang.org
Join Slack
What would be the right way to generate an UUID in kotlin?
a

Alin B.

almost 7 years ago
What would be the right way to generate an UUID in kotlin?
a
a
+2
  • 4
  • 16
  • 11286
after updating my project to Kotlin 1.8.0 I'm getting the following build error: ```Execution failed...
j

Jorge Domínguez

over 2 years ago
after updating my project to Kotlin 1.8.0 I'm getting the following build error:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> 'compileDebugJavaWithJavac' task (current target is 1.8) and 'kaptGenerateStubsDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: <https://kotl.in/gradle/jvm/toolchain>
but my Gradle config is:
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = "1.8"
}
so I'm not sure where target 17 is setup, has somebody experienced the same error?
j
d
b
  • 3
  • 4
  • 10013
Anyone know how to solve `Cannot use @TaskAction annotation on method AbstractKotlinCompile.execute(...
d

dave08

about 2 years ago
Anyone know how to solve
Cannot use @TaskAction annotation on method AbstractKotlinCompile.execute() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.
when upgrading from an older AGP version to 8.0.2?
d
a
  • 2
  • 5
  • 9135
I am trying to use a preview JDK in my Kotlin compiler config, but I am getting a strange error. Has...
g

Gavin Ray

over 2 years ago
I am trying to use a preview JDK in my Kotlin compiler config, but I am getting a strange error. Has anyone seen this before:
val JDK_21_PATH = "/home/user/.sdkman/candidates/java/21.ea.6-open"

tasks.withType<org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain>().configureEach {
    kotlinJavaToolchain.jdk.use(JDK_21_PATH, JavaVersion.VERSION_21)
}
Execution failed for task ':app:compileKotlin'.
> Error while evaluating property 'compilerOptions.jvmTarget' of task ':app:compileKotlin'.
   > Failed to calculate the value of property 'jvmTarget'.
      > Unknown Kotlin JVM target: 21
g
t
  • 2
  • 37
  • 6823
Hey I am experiencing a serious issue - it looks like mocking answer for a parametrised suspended me...
i

igor.wojda

almost 3 years ago
Hey I am experiencing a serious issue - it looks like mocking answer for a parametrised suspended method does not work as expected:
class ExampleUnitTest {
    private val repository = mockk<AlbumRepository>()

    private val cut = GetAlbumUseCase(repository)

    @Test
    fun `when execute return success`() {
        // given
        val albumName = "Thriller"
        val artistName = "Michael Jackson"
        val mbId = "123"

        // when
        val actual = runBlocking { cut.execute(albumName, artistName, mbId) }

        // then

    }
}
no answer found for: AlbumRepository(#1).getAlbumInfo(Thriller, Michael Jackson, 123, continuation {})
io.mockk.MockKException: no answer found for: AlbumRepository(#1).getAlbumInfo(Thriller, Michael Jackson, 123, continuation {})
	at app//io.mockk.impl.stub.MockKStub.defaultAnswer(MockKStub.kt:93)
The answer can't be found (most likely due to
continuation {}
param). I have crafted a sample project to reproduce this. Steps: 1. Open project using
Android Studio
2. Run
ExampleUnitTest
tests Can someone take a look? Is there any workaround?
TestMockk2.zip
i
c
n
  • 3
  • 14
  • 5821
I'm updating my multi-module multiplatform (android/ios/jvm) project from Kotlin 1.7.22 / Gradle 7.5...
r

ribesg

over 2 years ago
I'm updating my multi-module multiplatform (android/ios/jvm) project from Kotlin 1.7.22 / Gradle 7.5.1 to Kotlin 1.8.10 / Gradle 8.0 and have this issue:
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
Anyone encountered this? It's a lint task so it still builds, but it looks weird. (see logs in thread)
r
m
+5
  • 7
  • 56
  • 5553
I’m getting `No tests found for given includes` when trying to run a single kotest test inside a gra...
b

bbaldino

about 3 years ago
I’m getting
No tests found for given includes
when trying to run a single kotest test inside a gradle project--I assume this must be something dumb I’m missing but after googling around a bit I still haven’t seen anything that addresses it. I do have
tasks.withType<Test>().configureEach {
    useJUnitPlatform()
}
in build.gradle.kts
b
s
  • 2
  • 66
  • 5346
I am trying to implement a Room database but my app crashes
j

Jetbrains Ttvna

almost 2 years ago
I am trying to implement a Room database but my app crashes
not kotlin but kotlin colored 2
j
f
+2
  • 4
  • 33
  • 5282
I need to get context in view model , I am trying to get using localcontext but it is keep giving er...
j

Jitendra

about 3 years ago
I need to get context in view model , I am trying to get using localcontext but it is keep giving error @composable invocation can only happen from the context of composable function, what is the best way to get context/activity instance in viewsmodel
j
f
+2
  • 4
  • 3
  • 4794
What is the better way to mock date using mockk?
r

Recca Chao

almost 4 years ago
What is the better way to mock date using mockk?
r
e
+2
  • 4
  • 18
  • 4630
12Next

kotlinlang

A modern programming language that makes developers happier.

Powered by