1

Many people got this error. I have set java variable (JAVA_HOME) and in project structure set jdk path.

But for me it's not working. Here is a screenshot describing problem:

enter image description here

It's giving wrong tried location. Here's a screenshot: structure->module setting jdk location is

    C:\Program Files\Java\jdk1.7.0_67. 

But in error it's showing other location.

Could you tell me how to solve it?

prince
  • 113
  • 2
  • 9
  • you have a fresh installation and I see new project, please try to `Build->Clean`, then `Build->Rebuild`, if doesn't work `File->Invalidate caches/Restart` – piotrek1543 Jan 03 '16 at 16:49
  • Also go to your Module settings and reselect your java directory, I mean open dialog box how would you look foe another version, but select the existing (Please watch this: https://www.youtube.com/watch?v=t_LxlvPAp1Q). Then `Build-> Rebuild project` – piotrek1543 Jan 03 '16 at 16:51

4 Answers4

1

For me, I am doing very silly mistake. I was using proxy-server. I should use https server in-place of http server.

prince
  • 113
  • 2
  • 9
0

You need to set up system level JAVA_HOME variable.

Set JAVA_HOME:

Right click My Computer and select Properties.

On the Advanced tab, select Environment Variables, and then create or edit system variable JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.

Also there is PATH variable. You have to append JDK folder and JDK bin folder to that variable. For example:

C:\Program Files\Java\jdk1.6.0_02; C:\Program Files\Java\jdk1.6.0_02\bin

Note the semicolon, you have to use it to separate inputs. After that restart your computer. After restart in CMD prompt try:

echo %JAVA_HOME%

If everything is set up succesfully output should be:

echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_02
Tomislav
  • 3,181
  • 17
  • 20
  • I did this. But not working. As you can see error, it's giving wrong location(Tried location). Can you tell how to change location. – prince Jan 03 '16 at 16:47
  • Ok, pleas in your shell (command prompt) do: echo %JAVA_HOME% and give us output – Tomislav Jan 03 '16 at 16:52
  • One more doubt, where i have to give bin path. – prince Jan 03 '16 at 16:53
  • here is output of echo %JAVA_HOME%" C:/Program Files/Java/jdk1.7.0.67 – prince Jan 03 '16 at 16:54
  • PATH variable, in advanced system properties, Enviroment Variables, System variables. After that do restart just to be sure – Tomislav Jan 03 '16 at 16:55
  • for both path, variable name will be same? – prince Jan 03 '16 at 16:56
  • Are you using powershell for your comand prompt or CMD? echo %JAVA_HOME% gives you are configuration of system variable JAVA_HOME if it is set. Are you sure that you set JAVA_HOME variable in Enviroment variables? – Tomislav Jan 03 '16 at 16:57
  • yes I check both many times. You can see in error, in image. It is checking different location. Not my jdk location. I think that is problem – prince Jan 03 '16 at 16:59
  • @prince, here is tutorial to set system variables; https://www.youtube.com/watch?v=SnIkVKSed4I – Tomislav Jan 03 '16 at 16:59
  • I restarted system. But not working. Gradle build taking infinite time. "Gradle: Resolve dependencies':app_releaseComiple. " – prince Jan 03 '16 at 17:37
  • You can see my image. I am getting same error, after 20-25 min. – prince Jan 03 '16 at 17:56
0

It could be a problem with JDK configuration in you project. You can change this configuration in module settings, as explained in other stackoverflow question below

Android Studio - supplied javaHome is not a valid folder

Community
  • 1
  • 1
R. Suguro
  • 11
  • 3
  • As I said in my problem, I did that setting, but as in error it is giving different location. – prince Jan 03 '16 at 16:57
  • I am sorry, I didn't see your comment about JDK path. I had a similar problem with Android Studio when I changed JDK path in my project and I solved it after modify default sdk and jdk path configuration. I followed the steps below: Open Android Studio Go to Quick Start -> Configure -> Project Defaults -> Project Structure Change the JDK location Close and Open Andoid Studio But I don't know if you tried this approach. – R. Suguro Jan 03 '16 at 19:13
  • Thanks for reply but it didn't help. – prince Jan 04 '16 at 10:19
0
  1. You can delete your Java from your system and reinstall the latest version.

check the folder that you've pointed to... That's the problem you got there, The Android Studio couldn't find the JDK. make sure you point Android Studio where your JDK is properly.

Ajithesh N
  • 66
  • 9