Reputation: 1435
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?
Upvotes: 143
Views: 227323
Reputation: 415
To solve Invalid Gradle JDK configuration found.
you have to download the specific jdk for specific Gradle version that you used in your project .
Please find the Java compatibility table link .
https://docs.gradle.org/current/userguide/compatibility.html
and set to the gradle jdk .and find image to set the version
Upvotes: 1
Reputation: 1317
I ran into this because I had upgraded Gradle and Java version on one branch and then pulled down a colleague's branch that was still on the old versions. Fixed it by setting the Java version back.
Upvotes: 0
Reputation: 1
Try to put the JRE path inside the IDE folder. Another way is to put JAVA_HOME, configuring in the global variables of windows.
Upvotes: 0
Reputation: 309
For me I just did File -> Invalidate Caches... -> Invalidate And Restart(leave the checkboxes above as default) It will take some time but it worked fine .
Upvotes: 0
Reputation: 1223
To Solve this,
.gradle
and .idea
folder from your project.Invalidate Cache and Restart
Android studio.gradle
and .idea
foldersUpvotes: 10
Reputation: 4331
If you're working with Android Studio 4.2.2, and you got a zip of somebody's source code, it may often contain the .idea
folder. Unfortunately, the .idea
folder may contain gradle SDK configuration, etc., that are only valid for the computer of the person who sent you the source code.
Solution:
.idea/gradle.xml
and .idea/workspace.xml
.Then do the gradle sync
again and the error will go away, and it should be fine.
Upvotes: 3
Reputation: 1
Just deleted the entire .idea folder from your project and it will work.
Upvotes: 0
Reputation: 2742
Go to Android studio settings or preferences and select jdk as shown in image and try syncing project
Upvotes: 2
Reputation: 4442
I had to update to the latest Android build, Android Studio Arctic Fox | 2020.3.1.
to be specified to make the project compile.
Upvotes: 0
Reputation: 799
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
Upvotes: 6
Reputation: 1211
Simple solution:
Upvotes: 84
Reputation: 393
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
Upvotes: 38
Reputation: 1258
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.
Upvotes: 2
Reputation: 11
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
Upvotes: 0
Reputation: 15679
.idea
and .gradle
from the source directory.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.File -> Invalidate Caches/Restart
click Invalidate and RestartUpvotes: 0
Reputation: 7220
Just delete .idea
and .gradle
folders from your project path on your computer and sync again.
Upvotes: 8
Reputation: 2344
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.
Upvotes: 215
Reputation: 61
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.
Upvotes: 1
Reputation: 81
I have solve this problem my App name "Addvoicetomusic2"; go to app dir- C:\Users\amram\AndroidStudioProjects\Addvoicetomusic2
Upvotes: 5
Reputation: 979
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
Upvotes: 5
Reputation: 1
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.
Upvotes: 0
Reputation: 639
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:
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:
Upvotes: 17
Reputation: 7
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.
Upvotes: 0
Reputation: 407
When I encountered this same problem, I solved it by specifying the path to the portable (non installed) JDK8.
Upvotes: 0
Reputation: 1346
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.
Upvotes: 123