1

I need to enable Java8 support in my project. All the answers that I find are outdated and I can't figure out what actually has to be done. So far I have done this :

1. Added compileOptions :

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

This gives me the error below :

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


ERROR: Jack is required to support Java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8.
  1. I tried to enable jack using jackOptions. But the gradle could not identify jackOptions. I read somewhere that jack is deprecated. I have not idea where to go from here.

gradle version : 4.10.3

Zoe
  • 27,060
  • 21
  • 118
  • 148
iammrmehul
  • 730
  • 1
  • 14
  • 35

3 Answers3

0
If you are building using commandline instead of android-studio.
export ANDROID_HOME=/android/SDK_26
export JAVA_HOME=/sw/licensed/sun/jdk/1.8.0_91
export PATH=$JAVA_HOME/bin:$PATH
chmod 777 gradlew
./gradlew
./gradlew assembleDebug

SDK_26: This is SDK-26 toolchain downloaded using sdk-manager.
Ranjan Kumar
  • 1,164
  • 7
  • 12
0

You should add to repositories google() and try

or

I am not sure but this can be help to you.

Clean project -> delete .idea and .gradle files -> invalidate cache and restart -> build project

Beyazid
  • 1,795
  • 1
  • 15
  • 28
-3

Try enable jackOptions, like here:

android {
....
defaultConfig {
 ...
  jackOptions {
    enabled true
  }
}

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