The location of the Android Studio JDK changes to 1.7 every time it updates to 1.8 paths

I recently installed jdk 1.8 u92 after Android Studio stated that it was needed to build api24. However, I ran into this problem now.

I reviewed some other solutions and deleted jdk 1.7, added environment variables for JDK_HOME, JAVA_HOME and JAVA8_HOME. The problem still persists.

Every time I try to create an application, gradle crashes with an error, and Android Studio asks me to Choose a valid JDK directory . Then I go to Project Structure => JDK Location and update it to 1.8 folder. Trying to build again gives the same error, and when I check the project structure, the path automatically reverts to the old JDK 1.7.

Is there any fix for this problem?

+16
java android android-studio java-8
Jun 28 '16 at 4:15
source share
6 answers

I thought about it by looking at a few files in the Android studio settings directory.

If you updated your Android studio and imported settings from previous installations, this may happen (it may happen with a new installation).

Decision:

  • Go to the folder where your Android Studio configuration is located (usually in $ HOME / .AndroidStudio2.1 / confg).
  • Open the Options folder and delete the jdk.table.xml file (keep a backup just in case)
  • Restart Android Studio

This solved the problem for me. The newly created jdk.table.xml file will have updated java8 values ​​(which are most likely extracted from the JDK_HOME environment variable).

+31
Jun 28 '16 at 4:39
source share
  • close studio android studio

  • go to:

C: \ Users \ WINDOW_USER_NAME \ AndroidStudio2.1 \ Config \ options

open jdk.table.xml

  1. replace everything with your version of the JDK, in my case everything has been replaced:

    C: / Program Files / Java / jdk1.8.0_101

  2. reopen android studio

  3. Synchronize

+1
Jan 08 '17 at 9:45
source share

What you want to do after deleting the xml file is NOT to close Android studio before that. Because when the android boots up again, it will check its referral settings and say: “Oh, this user may have deleted the jdk table, but by default it still had 1.7 selected.”

No, when you delete the table file, keep the studio open. Then select 1.8 so that it saves the original settings back to the table. You may not have to reload it, because the table xml file is not the current file, because it is located in the profile folder of your own users, and not in the program files.

0
29 Sep '16 at 0:39
source share

follow these steps: (steps for windows, access to the same directories in case of other operating systems)

Step 1: Press "Win + R", enter "% userprofile%" and press the enter key.

Step 2: Go to the Android Studio folder, which will be in the following format - ".AndroidStudio2.2" (version may vary)

Step 3: Go to the "config \ options" folder.

Step 4: Make a copy of jdk.table.xml on the desktop and delete jdk.table.xml . (Do it while the android studio is still working)

Step 5: In the android -Go studio in "File-> Project Structure" and select the correct jdk path.

If STEP 4 and STEP 5 do not solve the problem, follow these steps:

Step 4 ': Open jdk.table.xml in notepad.

Step 5 ': Find all the words, including the jdk version - for example. find "1.8.0_45"

Step 6 ': Replace the found words; with your current jdk version. E.g. change "1.8.0_45" to "1.8.0_111" (make sure you replace all fields containing the version number)

Step 7 ': Save the jdk.table.xml file

Step 8 ': Restart Android Studio.

This will definitely solve the problem.

PS: JDK must be installed and the path must be installed.

0
Dec 22 '16 at 18:19
source share

Just for me, this answer is: https://stackoverflow.com/a/316618/

Both the android SDK and the JDK folders should not contain spaces.

0
Nov 07 '17 at 22:18
source share

1) Add this to your build.gradle application (inside the android element)

 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 

I copied this with https://stackoverflow.com/a/312929/ Thanks go to the person who posted this ( https://stackoverflow.com/users/2910520/matpag ), but the correct answer is not published anywhere on this subject.

0
Jul 09 '19 at 2:04
source share



All Articles