Invalid Gradle JDK configuration found?
AndroidGradleAndroid Problem Overview
I am very new in Android Studio
. I have a problem with gradle
.
it says,
Error:Invalid Gradle JDK configuration found.
Platform SDK does not point to valid `JDK` `(C:/Program Files/Java/jdk1.8.0_20)`.
Consult IDE log for more details (Help | Show Log)
then what should I do to solve that?
Android Solutions
Solution 1 - Android
I got this issue in Android studio 4.2 canary, and I had to delete those generated files:
.idea/gradle.xml
.idea/workspace.xml
then clicking try again to sync the project.
Solution 2 - Android
Under Android Studio, select File > Project Structure > JDK location
.
Specify the JDK to the folder of your currently installed JDK. And specify the SDK location as well.
Solution 3 - Android
Simple solution:
- Go to build.gradle and at the top there will be a message JDK missing
- Click on it and use JDK from the list (or download one if you don't have)
- Sync project
Solution 4 - Android
I got this issue in Android Studio 4.2.2, and the solution is very simple, just delete
.idea/gradle.xml
.idea/workspace.xml
and click on
File -> Invalidate Caches/ Restart
Solution 5 - Android
If you want / need to, update your JDK installation to the version that you want to use.
Next, find the version for your current JDK installation by running javac -version
or java -version
. Check that it is what you expect.
Next, find the JDK installation directory:
- It should be on your %PATH%.
- By default it will be a subdirectory of "C:\Program Files\Java"' for example: "C:\Program Files\Java\jdk1.8.0_45"
Next, start Android Studio, and go to the "File->Project Structure->JDK Location" preference page.
The file path given by the preference should be the path to the JDK installation director that you identified above. If it isn't then update it.
Notes:
- Use the full pathname of the installation directory; e.g. "C:\Program Files\Java\jdk1.8.0_45".
- Use a pathname, not a URL.
Solution 6 - Android
Just delete .idea
and .gradle
folders from your project path on your computer and sync again.
Solution 7 - Android
This issue happens if you change the workspace or manually copy files to the new repo workspace. i fixed it by deleting below files,
.idea/gradle.xml
.idea/workspace.xml
Finally click on File-> invalidate cache and restart
Solution 8 - Android
For Android studio Canary Build Arctic Fox 2020.3.1 this seems like a bug or hard dependency with Jdk 11.
I already had jdk defined, but I was still getting this error. Got resolved after installing jdk 11 and providing path to it in the jdk location here
File > Project Structure > JDK location
Solution 9 - Android
I have solve this problem my App name "Addvoicetomusic2"; go to app dir- C:\Users\amram\AndroidStudioProjects\Addvoicetomusic2
- then remove .gradle and .idea file *then connect to internet
- restart android studio project successfully solve
Solution 10 - Android
This Problem occurs when you open your Android Project in Another Computer.
To Solve this,
- DELETE your
.gradle
and.idea
folder from your project. - Invalidate Cache and Restart Android studio
- After Restart, SYNC Again to created new
.gradle
and.idea
folders
Solution 11 - Android
Solution for Android 4.2.2
Terminal commands:
rm .idea/gradle.xml
rm .idea/workspace.xml
Finally click on File-> invalidate cache and restart
Solution 12 - Android
The simple and easy way is
>> Go To Your build.gradle(Module:app) >> At the top right corner you will find notification JDK is missing or download missing JDK >> Clik on that notification and download JDK and Sync Project.
Solution 13 - Android
SIMPLE SOLUTION -go to build.gradle and at Top there missing JDK right side configuration or download options to click and install JDK and have a already JDK then select it. Otherwise download better option. Thanks click sync now or try again.
Solution 14 - Android
For macOS:
-
install JDK from Oracle site
-
Go to the folder:
cd /Library/Java/JavaVirtualMachines
Here you will see JDK installed.
Set folder in the Android Studio, something like this:
/Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk
I don't why it's not possible to automate such tasks after all this years.
Solution 15 - Android
amra ram's solution worked for me, more or less. I had an old .idea
directory with a weird configuration. Deleting it, closing Android Studio, and opening the project again forced it to reinstall and sync Gradle.
Solution 16 - Android
- Go to build.gradle and at the top there will be a message JDK missing
- Click on it and use JDK from the list (or download one if you don't have)
- Sync project
Solution 17 - Android
When I encountered this same problem, I solved it by specifying the path to the portable (non installed) JDK8.
Solution 18 - Android
Same error i got when I install android studio on my pc . at the time of installation I have installed android sdk and android studio in different path so In project structure I have set my new sdk path . Still I got message of invalid jdk ...then I knew location of jdk ,again in project structure I have set my jdk path.It works.
Solution 19 - Android
For me the problem appeared after updating IntelliJ to version 2020.2.1.
Just solved it by going to Project Structure -> SDK. There I only had the Java jdk. I've added IntelliJ IDEA Platform Plugin SDK and that seems to have solved the problem. gradle loads just fine.
Solution 20 - Android
if other answers not work try this
For Android Studio Arctic Fox | 2020.3.1 Canary 15
File -> Invalidate Caches/Restart
click Invalidate and Restart
it works for me
Solution 21 - Android
- First you have to delete the folders -
.idea
and.gradle
from the source directory. - Select
File > Project Structure > JDK location
. Specify the JDK to the folder of your currently installed JDK. Ensure that you have installed the JDK version greater than 1.8. Also specify the SDK location. - Select
File -> Invalidate Caches/Restart
click Invalidate and Restart
Solution 22 - Android
Just clean and rebuild project worked for me.
Solution 23 - Android
I had to update to the latest Android build, Android Studio Arctic Fox | 2020.3.1.
to be specified to make the project compile.
Solution 24 - Android
Go to Android studio settings or preferences and select jdk as shown in image and try syncing project
Solution 25 - Android
Just deleted the entire .idea folder from your project and it will work.