5

I have changed sourceCompatibility and targetCompatibility to JavaVersion.VERSION_11 in build. gradle files for all modules. In my PC I have JDK 11, JAVA_HOME and path are ok, in project:

enter image description here

But I still get Failed to apply plugin 'com.android.internal.application'. Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: changing the IDE settings. changing the JAVA_HOME environment variable. changing org.gradle.java.homeingradle.properties`

my gradle.properties: org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true android.useAndroidX=true android.enableJetifier=true

Monica
  • 384
  • 2
  • 4
  • 16

2 Answers2

7

if you're using mac, Check you're java version on android studio. point to android studio menu then preference or command + ,

enter image description here

Update bash profile to java 11 which android Studio has.

vim /users/{username}/.bash_profile

locate path variable java to android folder folder

/Applications/Android Studio.app/Contents/jre/Contents/Home/bin

enter image description here

dont forget to type

source /Users/{username}/.bash_profile 

finally check our java version, type

which java && javac --version 

or running ./gradlew --version

reggi49
  • 460
  • 3
  • 11
0

Can you check java path in Environment variables and make sure you don't have Java 8 in path and you have java 11 or newer

Islam Assem
  • 1,376
  • 13
  • 21