declaration of ‘java.lang.invoke.LambdaMetafactory‘ appears in /apex/com.android.runtime/javalib/cor

The error message is as follows:

 java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; in class Ljava/lang/invoke/LambdaMetafactory; or its super classes (declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar)

Reason: The code in the third-party dependency package uses Lambda expressions. Lambda expressions are a new feature of JDK8, so just set the JDK version.

File -> Project Structure->Modules -> Properties and set Source Compatibility and Target Compatibility to JDK8.

1. Configure in build.gradle:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

two, or 

Guess you like

Origin blog.csdn.net/gxhea/article/details/122260628