gpt4 book ai didi

java - 在android studio中的java 8中使用lambda

转载 作者:行者123 更新时间:2023-12-02 03:11:32 25 4
gpt4 key购买 nike

我使用带有 lambda 表达式的 java 8 并收到此错误我的代码如下:

Predicate<Site> predicate = c-> c.id == filter.get(0);

并收到以下错误:

12-05 10:57:44.745 25416-25416/khabarazma.com E/AndroidRuntime: FATAL EXCEPTION: main
Process: khabarazma.com, PID: 25416
java.lang.NoClassDefFoundError: chitva_Pages.-$Lambda$17
at chitva_Pages.Search$LoadFilter.lambda$-chitva_Pages_Search$LoadFilter_lambda$20(Search.java:3787)
at chitva_Pages.-$Lambda$8.$m$0(Unknown Source)
at chitva_Pages.-$Lambda$8.onClick(Unknown Source)
at android.view.View.performClick(View.java:4455)
at android.view.View$PerformClick.run(View.java:18448)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5064)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
at dalvik.system.NativeStart.main(Native Method)

有人可以帮助我吗?

最佳答案

您是否已设置 this page 中描述的所有所需内容? ?

您应该为 java8 功能配置 Gradle:

android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

关于java - 在android studio中的java 8中使用lambda,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40969241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com