skip to Main Content

I have added JAVA 11 to android studio to Build Tools -> Gradle like below:

enter image description here

app/build.gradle:

enter image description here

SDK:

enter image description here

Still when checking source it still shows JAVA 8:

enter image description here

and also when app runs, the features on Java 11 which don’t exist on Java 8 cause the app to fail with missing exception.

java -version shows:

openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
OpenJDK 64-Bit Server VM (build 11.0.11+0-b60-7772763, mixed mode)

2

Answers


  1. Try first to invalidate cache and watch carefully with XMLs Android studio need a proper cross checking but strangely its configuration process is not properly align.

    If unable to do this restore /Reset Android Studio then Add/Enable JAVA.

    Login or Signup to reply.
  2. Don’t forget to add java version in app level build.gradle file.

       compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    

    like the image bellow

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search