java.lang.NoSuchMethodError: No static method metafactory(Ljava/lang/invoke/MethodHandles$Lookup;

Exception information:

Android Studio报错java.lang.NoSuchMethodError...declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/core-oj.jar: 

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 project does not support Lambda syntax, and the code in the referenced third-party dependency package uses Lambda-style expressions.

Lambda expression is a new feature of JDK8. If the project is not configured with JDK8, an error will be reported.

solution:

Project settings compile JDK, click File -> Project Structure->Modules -> Properties and set Source Compatibility and Target Compatibility to JDK8, as shown in the figure below

Then click apply, click OK, it is best to clean and Sync, and run again.

 

 

Guess you like

Origin blog.csdn.net/qq_37980878/article/details/116852571