美文网首页
开启java8中的LAMBDA

开启java8中的LAMBDA

作者: 12排 | 来源:发表于2016-12-29 10:44 被阅读45次
使用兰姆达表达式

使用java8的兰姆达表达式会报错:

Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.

需要在build.gradle文件中添加:

android {
  ...

  compileSdkVersion 25
  buildToolsVersion "25.0.2"
  defaultConfig {
  ...
    jackOptions {
      enabled true
    }
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
} 

相关文章

网友评论

      本文标题:开启java8中的LAMBDA

      本文链接:https://www.haomeiwen.com/subject/zhiuvttx.html