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

Lambda语法在Android Studio里面报错

详细错误信息:

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)

        at com.luck.picture.lib.widget.FolderPopWindow.initView(FolderPopWindow.java:99)

        at com.luck.picture.lib.widget.FolderPopWindow.(FolderPopWindow.java:89)


原因:其实就是项目中有第三方的依赖包里面的代码使用了Lambda式的表达式

解决方式:

Lambda表达式是JDK8的一个新特性,所以项目设置一下编译是JDK

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


你可能感兴趣的:(declaration of 'java.lang.invoke.LambdaMetafactory' appears in /apex/com.android.runtime/javalib/...)