Search code examples
javalambdakotlin

Kotlin cannot access kotlin.jvm.functions.Function1 when calling kotlin function with java lambda


I am trying to call the following Kotlin function from Java

override fun First(list: LinqList<ElementType>, condition: (ElementType) -> Boolean) : ElementType

like this

int first = list.First(list,(x) -> x == 5);

but i get the following error

Error java: cannot access kotlin.jvm.functions.Function1
  class file for kotlin.jvm.functions.Function1 not found

I have tried googling it but i can not find the answer anywhere

Thanks in advance


Solution

  • My problem got fixed when I configured Kotlin compiler and runtime for my Java module with the latest stable version (currently 1.3.30)

    Just go to Tools > Kotlin > Configure Kotlin in Project > Android with Gradle and choose your Java module with Single module radio button selected then select your version and OK.