6

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

3
  • stackoverflow.com/questions/66980512/… Commented May 6, 2022 at 12:31
  • @Manohar, I have read this topic. I have the sane settings. But still get this error Commented May 6, 2022 at 12:34
  • 1
    Try restarting the system after changing the path variable. Commented May 7, 2022 at 8:00

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

5 Comments

yes, all my variables are ok.
Do you have java home variable in variables
yes. I have: CLASSPATH:C:\Program Files\Java\jdk-11.0.14\lib and JAVA_HOME: C:\Program Files\Java\jdk-11.0.14
you should have it in PATH ending with bin folder like following C:\Program Files\Java\jdk-14.0.1\bin
yes, I have this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.