Android 支持 Java8

版权声明:本文为博主原创文章,欢迎转载,转载请注明出处 https://blog.csdn.net/bedisdover/article/details/70502483

build.gradle文件配置如下:

android {
  ...
  compileSdkVersion 24
  buildToolsVersion "24.0.2"
  defaultConfig {
  ...
    jackOptions {
      enabled true
    }
  }

  compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
  }
} 

若未开启 Jack (Java Android Compiler Kit),则会报错

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

没有更多推荐了,返回首页