使用Java Lambda调用Kotlin函数时,Kotlin无法访问kotlin.jvm.functions.Function1 [英] Kotlin cannot access kotlin.jvm.functions.Function1 when calling kotlin function with java lambda

查看:310
本文介绍了使用Java Lambda调用Kotlin函数时,Kotlin无法访问kotlin.jvm.functions.Function1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Java调用以下Kotlin函数

I am trying to call the following Kotlin function from Java

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

像这样

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

但是出现以下错误

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

预先感谢

推荐答案

当我使用最新的稳定版本(当前为1.3.30)为Java模块配置Kotlin编译器和运行时时,我的问题得到解决.

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

只需转到工具> Kotlin>在Project中配置Kotlin> Android with Gradle ,然后选择 Single module 单选按钮,选择Java模块,然后选择您的版本和确定.

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.

这篇关于使用Java Lambda调用Kotlin函数时,Kotlin无法访问kotlin.jvm.functions.Function1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆