每次更新到 1.8 路径时,Android Studio JDK 位置都会变回 1.7 [英] Android Studio JDK location changes back to 1.7 every time it is updated to 1.8 path

查看:31
本文介绍了每次更新到 1.8 路径时,Android Studio JDK 位置都会变回 1.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android Studio 说 api24 构建需要 jdk 1.8 u92 之后,我最近安装了它.但是,我现在遇到了这个问题.

I recently installed jdk 1.8 u92 after Android Studio said it is needed for api24 builds. However, I've run into this issue now.

我查看了一些其他解决方案并卸载了 jdk 1.7,为 JDK_HOME、JAVA_HOME 和 JAVA8_HOME 添加了环境变量.问题依旧.

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

每次我尝试构建应用程序时,gradle 同步都会失败,Android Studio 会要求我选择一个有效的 JDK 目录.然后我转到 Project Structure => JDK Location 并将其更新到 1.8 文件夹.再次尝试构建会出现同样的错误,当我检查项目结构时,路径会自动设置回旧的 JDK 1.7.

Every time I try to build the app, gradle sync fails and Android studio asks me to Choose a valid JDK directory. I then go to Project Structure => JDK Location and update it to the 1.8 folder. Trying to build again gives the same error and when I check the Project Structure, the path is set back to the old JDK 1.7 automatically.

有没有解决这个问题的方法?

Is there any fix for this issue?

推荐答案

查看 Android Studio 设置目录中的几个文件后想通了.

Figured it out after looking at a few files inside the Android studio settings directory.

如果您一直在升级 Android Studio 并从以前的安装中导入设置,则可能会发生这种情况(全新安装也可能会发生这种情况).

If you've been upgrading your Android Studio and importing settings from previous installations, this might happen (it might also happen with a fresh installation).

解决方案:

  1. 转到您的 Android Studio 配置文件夹所在的任何位置(通常位于 $HOME/.AndroidStudio2.1/confg).
  2. 打开Options文件夹并删除文件jdk.table.xml(保留备份以防万一)
  3. 重启 Android Studio
  1. Go to wherever your Android Studio config folder is located (usually at $HOME/.AndroidStudio2.1/confg).
  2. Open the Options folder and delete the file jdk.table.xml (keep a backup just in case)
  3. Restart Android Studio

这为我解决了这个问题.新创建的 jdk.table.xml 将更新 java8 值(它很可能从 JDK_HOME 环境变量中获取).

This fixed the issue for me. The newly created jdk.table.xml will have updated java8 values (which it most probably fetches from the JDK_HOME environment variable).

这篇关于每次更新到 1.8 路径时,Android Studio JDK 位置都会变回 1.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆