Monica
Monica

Reputation: 436

After changed JAVA.VERSION to 11 I get "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8"

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

Upvotes: 6

Views: 12902

Answers (2)

reggi49
reggi49

Reputation: 560

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

Upvotes: 7

Islam Assem
Islam Assem

Reputation: 1512

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

Upvotes: 0

Related Questions