我试图从Java调用以下Kotlin函数

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

推荐答案

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

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.

Kotlin相关问答推荐

这些Kotlin函数等效吗?

Compose:LaunchedEffect在密钥更改后不会重新启动

有没有办法在 jetpack compose 中将 TextField 密码点图标增加得更大?

为何Kotlin标准库中的AND和OR函数不能像&&和||一样进行短路运算?

Kotlin 获取继承类的默认 hashCode 实现

TzdbZoneRulesProvider 在 java.time 中不工作

有什么方法可以要求在 kotlin 中的类型参数上进行注释?

关于 Kotlin 函数类型转换的问题

内联函数导致单元测试代码覆盖率报告出错

如何在 Kotlin 中创建一个打开新活动(Android Studio)的按钮?

如何在 Spring WebFlux 的响应正文中流式传输二进制数据

如何使用Kotlin Dokka记录主构造函数参数

为什么 Kotlin Pair 中的条目不可变?

如何将命令行参数传递给Gradle Kotlin DSL

如何从kotlin中的类实例化对象

在 Kotlin 函数上使用 Mokito anyObject() 时,指定为非 null 的参数为 null

Kotlin - 具有私有构造函数的类的工厂函数

kotlin中的全局可拓函数

Android Kotlin .visibility

Dagger 2 androidx fragment不兼容类型