Whenever I debug my app and put a breakpoint anywhere and open evaluate window, the lambda expressions are not working. (It works without any issues within the app itself)
Example code I have:
Arrays.asList("1One","1Two","1Three","1Four","2Five").stream()
.filter(word -> word.charAt(0) == '1')
.collect(Collectors.toList());
In the app it works without any issues. But in evaluate window it throws:
Compilation failed:
cannot find symbol
symbol: method metafactory(java.lang.invoke.MethodHandles.Lookup,java.lang.String,java.lang.invoke.MethodType,java.lang.invoke.MethodType,java.lang.invoke.MethodHandle,java.lang.invoke.MethodType)
location: interface java.lang.invoke.LambdaMetafactory
I updated Android studio to the latest version but the issue remains. How can I fix this error? When I started the project I was using JDK 1.8 but due to adding kotlin or updating gradle I had to update it to JDK 11. Here is some additional info about app setup:
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.gradleVersion = '7.2.2'
ext.kotlinVersion = '1.7.10'
ext.rxJavaVersion = '3.0.3'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradleVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module:app)
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.myschedule"
minSdk 27
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
sourceSets {
main {
assets {
srcDirs 'src\\main\\assets'
}
}
}
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.work:work-multiprocess:2.7.1'
implementation 'androidx.concurrent:concurrent-futures:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "io.reactivex.rxjava3:rxjava:$rxJavaVersion"
implementation 'androidx.preference:preference:1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}