Error:Jack is required to support java 8 language features [duplicate]
Asked Answered
E

1

138

When I tried to update my android project to use Java 8 after getting android studio 2.1 and android N SDK by adding

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

I had this error

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

What should I do?

Erwin answered 3/5, 2016 at 12:24 Comment(2)
show build.gradle fileLoquacity
See #36880615Grannie
L
323

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

The error say that you have to enable Jack.

To enable support for Java 8 in your Android project, you need to configure your build.gradle file like that

android {
  ...


  compileSdkVersion 23
  buildToolsVersion "24rc2"
  defaultConfig {
  ...
    jackOptions {
      enabled true
    }
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
} 
Loquacity answered 3/5, 2016 at 12:32 Comment(13)
After adding the following line I get Error:A problem occurred configuring project ':app'.Febrific
@AdityaKamath post your problem in new question so I can help you.Loquacity
Adding retroLambda solved that problem for me. github.com/evant/gradle-retrolambdaHorotelic
Does this work with annotation processing, or would it break compilation?Brose
Luckily we won't need this in a few weeks. Android will have full support for Java 8 language features. Jack will be deprecated. More details here: android-developers.googleblog.com/2017/03/…Nebulous
Jack is no longer required. See this: developer.android.com/studio/preview/features/…Brose
@Brose Were you able to remove jackOptions and still get Java 8 to work?Covell
@Covell At this point, Java 8 works without Jack.Brose
@Brose If I remove the jackOptions block from my Gradle, it still throws an error. Are you using retroLambda?Covell
@Covell Not using any of the legacy plugins. Read: developer.android.com/studio/write/java8-support.htmlBrose
To avoid Jack just update your Gradle to 3.0.0-beta1 . Built-in support for Java 8 libraries and certain Java 8 language features. Jack is no longer required, and you should first disable Jack to use the improved Java 8 support built into the default toolchain. . check this one developer.android.com/studio/build/gradle-plugin-3-0-0.htmlPibroch
Did anyone got this error :transformClassesWithPreJackPackagedLibrariesForDebug after adding jack ?Willard
@BiswasKhayargoli Yes i got that issue "transformClassesWithPreJackPackagedLibrariesForDebug". Any fixes for it?Sunlight

© 2022 - 2024 — McMap. All rights reserved.