Can I set java 11 by gradle in android project?

Viewed 167

I need to set java 11 for build android project anywhere (on build machine for example). I found gradle feature toolchain but I can't find right way to use it in android project. I tried to add in app module build.gradle:

apply plugin: 'com.android.application' 

//first way
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(11)
    }
}

android {
    //second way
    java {
        toolchain {
            languageVersion = JavaLanguageVersion.of(11)
        }
    }

but I still get error:

Task :my-library-module-name:compileDebugJavaWithJavac FAILED An exception has occurred in the compiler (1.8.0_282). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)

where my-library-module-name this is my another android lib gradle module which connected to app module.

It is possible to use gradle toolchain in android project?

0 Answers
Related