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

报错信息如下:

 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)

原因:第三方的依赖包里面的代码使用了Lambda表达式,Lambda表达式是JDK8的一个新特性,所以设置一下JDK版本就可以了

File -> Project Structure->Modules -> Properties  设置Source Compatibility和 Target Compatibility两项设置为 JDK8就可以了

一、在build.gradle里配置:

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

二、或 

猜你喜欢

转载自blog.csdn.net/gxhea/article/details/122260628