Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile android app with java 11 dependencies

I am trying to build an android app with some dependencies compiled in java 11.

I have configured this in the build.gradle :

android {
  compileOptions {
      sourceCompatibility = 1.11
      targetCompatibility = 1.11
  }
    ...
}

And I have configured my project structure with the java 11 sdk.

I am using this version of the android tool build plugin :

classpath 'com.android.tools.build:gradle:3.5.3'

And this version of gradle :

distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

I am also pointing to java 11 for the Gradle JVM.

But when I compile the app, I always get this error :

Execution failed for task ':app:compileDevJavaWithJavac'.
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.

I do not understand why.

I have checked my JAVA_HOME and my java -version and they both point to 11.

Does anybody has an idea of what is going on ?

Thanks

like image 455
hachiko Avatar asked Jan 17 '20 15:01

hachiko


1 Answers

Try like this :

compileOptions {
    targetCompatibility JavaVersion.VERSION_11
    sourceCompatibility JavaVersion.VERSION_11
}
like image 109
dgp Avatar answered Oct 01 '22 14:10

dgp