Table of Contents
Hide
- Solution 1. Set JDK version in gradle.properties file
- Solution 2: Set Gradle JDK in IDE settings
- Solution 3: Wrong JAVA_HOME environment variable
- Solution 4: Unmatched JAVA_HOME and Installed Java
- Solution 5: Set compileOptions in build.gradle(:app)
-
Conclusion
- Related Posts
To resolve Execution failed for task ‘:compileJava’. > invalid source release:11 error, we need to check if gradle is referencing the correct version of java.
Solution 1. Set JDK version in gradle.properties
file
gradle.properties file holds the project wide gradle settings. Any configuration done in IDE overrides the settings in this file.
To define a JDK version for the project, we can add it’s path in this file.
Open gradle.properties
file in your project and add this line –
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home/
Change the path of jdk according to the path in your system.
Solution 2: Set Gradle JDK in IDE settings
We can explicitly set the JDK in IntelliJ Android IDE. All we need to do is to follow these steps –
-
Open IDE Settings from
File
->Settings
. You can also use the shortcutctrl + alt + s
. - Choose
Build, Execution, Deployment
option from left menu. - Select
Build Tools
->Gradle
- In right pane, select appropriate Gradle JDK from the list.
Check how it looks like in this screenshot –
Solution 3: Wrong JAVA_HOME environment variable
If we have not set the JDK version in IDE then it will take it from JAVA_HOME environment variable.
Check if you set the correct path for JAVA_HOME. Follow these steps –
System Properties
-> Advanced (Tab)
-> Environment Variables
Solution 4: Unmatched JAVA_HOME and Installed Java
If you have a different version of Java than what is set in JAVA_HOME, then you will face unexpected outcomes. One of them is invalid source release error.
To understand this, first check the java version using this command –
java -version
Then check your JAVA_HOME environment variable and verify if the version matches in both.
If the version doesn’t match then it means JAVA_HOME is referring a version installed in user profile or some other location.
Solution 5: Set compileOptions
in build.gradle(:app)
You can indicate gradle which version to use by setting java reference variable in build.gradle(:app)
file.
Open build.gradle
file in app
module and set compileOptions
–
compileOptions { sourceCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_11 }
Check it out in this screenshot –
Conclusion
Gradle throws error Execution failed for task ‘:compileJava’ when something is preventing java to run the compiler. The second part of the error clears it – invalid source release:11. It means that we mentioned java version 11 but either it is not installed in system or the path variables are wrong.
In this article we saw 5 different reasons for this error and their solutions.
This is Akash Mittal, an overall computer scientist. He is in software development from more than 10 years and worked on technologies like ReactJS, React Native, Php, JS, Golang, Java, Android etc. Being a die hard animal lover is the only trait, he is proud of.
Related Tags
- Error,
- gradle,
- gradle-error,
- java error,
- java short
HomeAndroid developmentAndroid Gradle plugin requires Java 11 to run. You are currently using Java 1.8
May 24, 2022
Hello all in this Android solution, I will discuss a problem I’m currently experiencing in Android Studio. Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. Today I downloaded and installed Android studio’s most recent version, but I’m getting an error message like this: Android Gradle plugin requires Java 11 to function. The current version of Java is Java 1.8 for Java. Therefore, I am going to explain to you the possible solutions to this issue. So, let’s begin this article to resolve this issue.
How did This Error Come into your project?
I just installed Android studio’s latest version but I am experiencing this error. The other problem because you’ve used the most up-to-date android libraries and plugins. Also, our project runs on an older version of SDK and plugins.
How To Solve Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 Error?
If the JVM points to version 1.8 then you can change it from the android studio settings. You can click on File–>Setting–>Build, Execution, Deployment → Build Tools → Gradle → *Gradle JDK. And Apply then click on OK
How To Fix Android Gradle issue? is a requirement for Java 11 to run. Currently working with Java 1.8 Problem?
For Finding the Android Gradle build plugin requires Java 11 to run. The Java currently your are using 1.8 Error If you find that the JVM indicates version 1.8 Then you must alter it in the settings.
- Youo can find it inside the Preferences. And Select Build Execution, Deployment -> Build Tools -> Gradle. And Choose Gradle JDK to 11. The other option you can Download Page. Install JDK ZIP file. JDK ZIP file on your system.
- (Let’s say Windows)Extract the file to any folder with permissions that are high in your PC’s main directory. Now, open it and go to your Android studio project structure in men File* – The project structure. Then paste the directory in which you extracted the JDK version to this page. As you can see my version is JDK 16 at present and is installed in the directory.
Solution 1: Android Gradle plugin requires Java 11 to run
- If the JVM is pointed to Gradle version 1.8 then you must modify it from the settings.
- It is located in the File -> preferences.
- After that Select Build, Execution, Deployment.
- And Build Tools.
- Then, Gradle.
- Select Gradle JDK to 11.
- The problem must be resolved.
Solution 2: Android Gradle plugin requires Java 11 to run
- Go to Download Page.
- Get JDK ZIP file. JDK ZIP file for your system. (Let’s say Windows)
- Extract it to any folder with permissions that are high in the main directory of your PC
- Then open and go to your Android Studio project structure. It is found in the Men File* — Structure of the project.
- Copy the directory from which you downloaded the JDK version of the software here. As you can see the version I have is JDK 16 at the moment and it is installed in that directory.
Read More Tutorial
- Codeplayon Jetpack Compose Tutorial
- Codeplayon Android Tutorial
- Codeplayon Flutter Tutorial
- Codeplayon on Github
Today We are Going To Solve Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 in Java. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.
Contents
- 1 How to Fix Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 Error?
- 1.1 Solution 1 : Change JVM points to version 1.8 in
- 1.2 Solution 2 : Select JDK 16
- 2 Conclusion
- 2.1 Also Read This Solutions
- How to Fix Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 Error?
To Fix Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 Error just Change JVM points to version 1.8 in . There are a few steps that will be useful o solve the error completely. So just try that: First of all change JVM points to version 1.8 in settings. And you can find it in preferences. Then Select Build, Execution, Deployment. And after it select build tools and Gradle. Then select Gradle JDK to 11. And your error will be solved. So just try these steps.
- Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8
To Fix Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8 Error just Select JDK 16. To solve this error follow these steps:
delete the folder for JDK 1.8 in your user folder and just restart your android studio.
Then there is option asking if you wanted to change which JDK to use or redownload 1.8. Then just select JDK 16. It will help you.
Solution 1 : Change JVM points to version 1.8 in
There are a few steps that will be useful o solve the error completely. So just try that:
- First of all change JVM points to version 1.8 in settings. And you can find it in preferences.
- Then Select Build, Execution, Deployment.
- And after it select build tools and Gradle.
- Then select Gradle JDK to 11.
And your error will be solved. So just try these steps.
Solution 2 : Select JDK 16
To solve this error follow these steps:
- delete the folder for JDK 1.8 in your user folder and just restart your android studio.
- Then there is option asking if you wanted to change which JDK to use or redownload 1.8.
- Then just select JDK 16.
It will help you.
Conclusion
So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.
Also Read This Solutions
- sh: react-scripts: command not found
- The minCompileSdk (31) specified in a dependency’s AAR metadata is greater than this module’s compileSdkVersion
- Create React App requires Node 14 or higher. Please update your version of Node
- DeprecationWarning: executable_path has been deprecated, please pass in a Service object
- cv2.error: OpenCV(4.5.2) color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor’