简体   繁体   English

在 Windows 7 上安装 Android Studio 失败,找不到 JDK

[英]Android Studio installation on Windows 7 fails, no JDK found

I downloaded Android Studio and attempted to launch the program.我下载了 Android Studio 并尝试启动该程序。

This is running on Windows 7 64-bit with Java 1.7.这是在带有 Java 1.7 的 64 位 Windows 7 上运行的。 During the installation, my Java 1.7 is detected, and the rest of the installation goes through just fine.在安装过程中,我的 Java 1.7 被检测到,安装的其余部分正常进行。 However, when attempting to launch the application from the desktop icon, nothing happens.但是,当尝试从桌面图标启动应用程序时,没有任何反应。 Looking at the task manager, a new process from the CMD is loaded.查看任务管理器,从 CMD 加载了一个新进程。 This is because it's attempting to run the batch file studio.bat .这是因为它试图运行批处理文件studio.bat

When I execute via CMD, I get the following error:当我通过 CMD 执行时,出现以下错误:

ERROR: cannot start Android Studio. No JDK found. Please validate
either ANDROID_STUDIO_JDK or JDK_HOME or JAVA_HOME points to valid
JDK installation. ECHO is off. Press any key to continue . . .

I've attempted to open the idea properties file to see if there was something I could configure for this ANDROID_STUDIO_JDK or something like that.我试图打开idea属性文件,看看是否可以为这个ANDROID_STUDIO_JDK或类似的东西配置一些东西。 However, I found nothing.然而,我什么也没发现。 I hope some of you can let me know if you were able to install this or if you are having problems as well.我希望你们中的一些人可以让我知道您是否能够安装它或者您是否也遇到问题。

Adding a system variable JDK_HOME with value c:\Program Files\Java\jdk1.7.0_21\ worked for me.添加一个值为c:\Program Files\Java\jdk1.7.0_21\ JDK_HOME系统变量 JDK_HOME 对我有用。 The latest Java release can be downloaded here .可以在此处下载最新的 Java 版本。

Additionally, make sure the variable JAVA_HOME is also set with the above location.此外,请确保变量JAVA_HOME也设置为上述位置。

OK, I figured out how fix this nasty bug.好的,我想出了如何修复这个讨厌的错误。

Before you start在你开始之前

Go to your Android Studio installation folder and locate the bin folder.转到您的 Android Studio 安装文件夹并找到 bin 文件夹。 Inside the bin folder, you will find studio.bat .在 bin 文件夹中,您会找到studio.bat Execute the file, and it'll show the error.执行文件,它会显示错误。 If it is about the Java path then follow the tip 1.如果是关于 Java 路径,请遵循提示 1。

Tip 1提示 1

When you set the path JAVA_HOME , etc., make sure not to include bin at the end of the path.当您设置路径JAVA_HOME等时,请确保不要在路径末尾包含bin This solved the issue for me.这为我解决了这个问题。

JAVA_HOME => C:\Program Files\Java\jdk1.7.0_21 JAVA_HOME => C:\Program Files\Java\jdk1.7.0_21

path => C:\Program Files\Java\jdk1.7.0_21\bin path => C:\Program Files\Java\jdk1.7.0_21\bin

It works fine with JDK 1.7 (I tried with 32 bit).它适用于 JDK 1.7(我尝试使用 32 位)。

If you do so, you can see the initial screen as below.如果这样做,您可以看到如下所示的初始屏幕。

在此处输入图像描述

Tip 2提示 2

Are you getting the below error message?您是否收到以下错误消息?

Your Android SDK is out of date or is missing templates.您的 Android SDK 已过期或缺少模板。 Please ensure you are using SDK version 22 or later.请确保您使用的是 SDK 版本 22 或更高版本。

This error probably occurs, because you have reference to your older SDK (that you downloaded with Eclipse ) in your path variable.可能会发生此错误,因为您在路径变量中引用了较旧的 SDK(您使用Eclipse下载的)。 Go to Environment variables and remove any reference to the old SDK folder and point it to new SDK folder that is found inside the Android Studio installation folder.转到环境变量并删除对旧 SDK 文件夹的任何引用,并将其指向 Android Studio 安装文件夹中的新 SDK 文件夹。

Save and restart Studio, things should work as expected now.保存并重新启动 Studio,现在应该可以正常工作了。

Tip 3提示 3

If you hate messing around with the path variable as given above by removing old references, simply follow the following steps to refer to new SDK path that comes with Studio.如果您讨厌通过删除旧引用来弄乱上面给出的路径变量,只需按照以下步骤引用 Studio 附带的新 SDK 路径。

*Project Defaults* -> *Project Structure* -> Click "New" -> Select "Android SDK" -> Select the SDK folder inside the studio installation. *Project Defaults* -> *Project Structure* -> Click "New" -> Select "Android SDK" -> Select the SDK文件夹。

With the last update of Android Studio, I have two versions of the IDE's launcher随着 Android Studio 的最后一次更新,我有两个版本的 IDE 启动器

One is called studio.exe and the other studio64.exe they are both on:一个叫做studio.exe ,另一个叫做 studio64.exe ,它们都在:

C:\Users\myUserName\AppData\Local\Android\android-studio\bin

You have to launch the one that matches your Java version 64 or 32 bit您必须启动与您的 Java 版本 64 或 32 位匹配的版本

I had the same issue.我遇到过同样的问题。 I got resolved setting up correctly the environment variables in windows, for instance:我解决了在 Windows 中正确设置环境变量的问题,例如:

JAVA_HOME -> C:\Program Files\Java\jdk1.6.0_45
path -> C:\Program Files\Java\jdk1.6.0_45\bin

I've tried so many of the answers here but none of them works , so I decided to mix some of the answers here and I am successful !我在这里tried了很多答案,但none of them works ,所以我决定在这里mix some of the answers ,我成功了

成功运行android

Step 1: Go to the system properties by right-clicking on My Computer or by pressing windows button on typing This PC and right clicking on it and selecting Properties .第 1 步:通过右键单击“我的电脑”或在键入This PC时按 Windows 按钮并右键单击它并选择“属性”,转到系统Properties

在此处输入图像描述

Step 2: Click the advanced system settings or Environment Variables第二步:点击advanced system settingsEnvironment Variables

Step 3: Take note that there are 2 different variable.第 3 步:注意有 2 个不同的变量。 What you need to create is system variables not user variables , when you clicked new type the following您需要创建的是system variables not user variables ,当您单击新类型时,请输入以下内容

Variable name: JAVA_HOME变量名: JAVA_HOME

Variable value: C:\Program Files\Java\jdk1.8.0_25\ (Note: Please check if the path is right, sometimes it is C:\Program Files (x86)\Java\jdk1.8.0_25 )变量值: C:\Program Files\Java\jdk1.8.0_25\ (注意:请检查路径是否正确,有时是C:\Program Files (x86)\Java\jdk1.8.0_25

Step 4: Run the android studio, no need to restart.第四步:运行android studio,无需重启。

Note:笔记:

* C:\Program Files\Java\jdk1.8.0_25\ depends entirely on the installation path of your JDK not JRE so don't be confused if you see something like the picture below. * C:\Program Files\Java\jdk1.8.0_25\完全取决于你的JDK的安装路径而不是JRE ,所以如果你看到类似下图的内容不要混淆。 Just enter the location of your jdk , in my case it is C:\Program Files\Java\jdk1.8.0_25\ .只需输入您的jdk的位置,在我的情况下它是C:\Program Files\Java\jdk1.8.0_25\

* Do not include the bin folder when you enter the Variable value. * 输入变量值时Do not include the bin folder

在此处输入图像描述

在此处输入图像描述

Edit: For Windows 8 and 10 Users: Try to run C:\Program Files\Android\Android Studio\bin\studio.exe instead of C:\Program Files\Android\Android Studio\binstudio64.exe编辑:对于 Windows 8 和 10 用户:尝试运行C:\Program Files\Android\Android Studio\bin\studio.exe而不是C:\Program Files\Android\Android Studio\binstudio64.exe

The path for the latest JDK.最新 JDK 的路径。 It worked very well.它工作得很好。

在此处输入图像描述

I had the same issue.我遇到过同样的问题。 I am having 64-bit windows 8. I downloaded the android studio which worked on a 32-bit machine but not on my 64-bit.我有 64 位 Windows 8。我下载了 android studio,它可以在 32 位机器上运行,但不能在我的 64 位机器上运行。

The solution for me was pretty simple.对我来说解决方案非常简单。 I navigated to我导航到

C:\Program Files (x86)\Android\android-studio\bin

there I saw 2 exe files studio.exe and studio64.exe .在那里我看到了 2 个 exe 文件studio.exestudio64.exe Normally my start menu was pointing to studio64.exe which always kept on giving me "The environmental variable JDK_HOME does not point to valid JVM".通常我的开始菜单指向 studio64.exe,它总是不断给我“环境变量 JDK_HOME 不指向有效的 JVM”。 So then I clicked studio.exe and it worked :)所以然后我点击了studio.exe并且它工作了:)

I hope this may help someone facing the same problem as me我希望这可以帮助面临与我相同问题的人

If you are getting message "Your Android SDK is out of date…" — click " Configure " —> " Project Defaults " —> " Project Structure ", pick " SDKs " —> " Android SDK " and in a " Build Target " choose " Android 4.2.2 ".如果您收到消息“您的 Android SDK 已过时...”-单击“配置”->“项目默认值”->“项目结构”,选择“ SDKs ”->“ Android SDK ”并在“构建目标”中选择“ Android 4.2.2 ”。 Click "OK".单击“确定”。 Now it should work fine.现在它应该可以正常工作了。

I got the problem that the installation stopped by the " $(^name) has stopped working " error.我遇到了由“ $(^name) has stop working ”错误停止安装的问题。 I have installed the Java SE Development kit already, and also set both SDK_HOME and JAVA_HOME that point to "C:\Program Files\Java\jdk1.7.0_21"我已经安装了 Java SE 开发工具包,并且还设置了指向“C:\Program Files\Java\jdk1.7.0_21”的 SDK_HOME 和 JAVA_HOME

My laptop installed with Windows 7 64 bits我的笔记本电脑安装了 Windows 7 64 位

So I tried to install the 32-bit version of the Java SE Development kit, and set my JAVA_HOME to "C:\Program Files (x86)\Java\jdk1.7.0_21", restart and the installation worked OK.所以我尝试安装 32 位版本的 Java SE 开发工具包,并将我的 JAVA_HOME 设置为“C:\Program Files (x86)\Java\jdk1.7.0_21”,重新启动,安装工作正常。

此问题已在 Android Studio v0.1.1 中修复,因此只需更新 Android Studio 即可。

Sometimes you can resolve this type of issue by setting environment variables so the process looks for the JDK in the right spot .有时您可以通过设置环境变量来解决此类问题,以便该过程在正确的位置查找 JDK

Another approach is to figure out where the process is looking, then put your JDK there.另一种方法是找出进程正在寻找的位置,然后将 JDK 放在那里。

I've had lots of success using Process Monitor from Sysinternals:我使用 Sysinternals 的Process Monitor取得了很多成功:

  1. Start -> Run -> procmon开始 -> 运行 -> procmon
  2. Go to the Filter menu, then select Filter...转到Filter菜单,然后选择Filter...
  3. Set Event Class is File System then Include设置Event Class is File System然后Include
  4. Add , then OK Add ,然后OK

This will filter down to all the file system operations taking place on your machine.这将过滤到您机器上发生的所有文件系统操作。

You could try filtering based on the result of the File System operation:您可以尝试根据文件系统操作的结果进行过滤:

  • Right click on the Result column, then Exclude 'SUCCESS'右键单击Result列,然后Exclude 'SUCCESS'

You can also quite easily filter based on the process name, either from the Filter... menu option or by right clicking on the Process Name column and selecting Include 'process.exe' .您还可以通过“ Filter...菜单选项或右键单击“ Process Name ”列并选择Include 'process.exe'进程名称来轻松地根据进程名称进行过滤。

Once you find the file system operation that's failing, the Path column will tell you where to put your JDK.一旦您发现文件系统操作失败, Path列将告诉您将 JDK 放在哪里。

I've found this to be very empowering.我发现这是非常有能力的。 Especially compared to the frustrating process of changing environment variables by trial and error.特别是与通过反复试验改变环境变量的令人沮丧的过程相比。

My issue was caused because I have an & character in my Windows user name, so when installed in the default path I was getting the following error after running bin/studio.bat我的问题是因为我的 Windows 用户名中有一个&字符,所以当安装在默认路径中时,运行bin/studio.bat后出现以下错误

                                               |
                                               v notice broken path
The system cannot find the file C:\Users\Daniel \studio64.exe.vmoptions.
Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/idea/Main
Caused by: java.lang.ClassNotFoundException: com.intellij.idea.Main
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: com.intellij.idea.Main.  Program will exit.

So I uninstalled and reinstalled it to program files and it launches fine now.因此,我将其卸载并重新安装到程序文件中,现在可以正常启动。

I couldn't get this to work no matter which environment variables I set.无论我设置哪些环境变量,我都无法让它工作。 So I simply put a copy of the JDK into my Android Studio installation folder.因此,我只是将 JDK 的副本放入我的 Android Studio 安装文件夹中。

  1. Copy the contents of the JDK installation (for example, C:\Program Files (x86)\Java\jdk1.7.0_21 )复制 JDK 安装的内容(例如C:\Program Files (x86)\Java\jdk1.7.0_21

  2. Paste them into the installation directory of the Android Studio (for example, C:\Program Files (x86)\Android\android-studio )将它们粘贴到 Android Studio 的安装目录中(例如C:\Program Files (x86)\Android\android-studio

I somewhat assumed that the issue was caused by having the x64 version of the JDK installed.我有点假设这个问题是由安装了 x64 版本的 JDK 引起的。 But what was especially confusing was the fact that I could start Android Studio just fine when I started the studio.bat as an Administrator (even though the environment variables were set for my personal user account).但特别令人困惑的是,当我以管理员身份启动studio.bat时,我可以很好地启动 Android Studio(即使环境变量是为我的个人用户帐户设置的)。

studio.bat will look for several valid options when determining which JDK to use.在确定使用哪个 JDK 时, studio.bat将寻找几个有效的选项。

:: Locate a JDK installation directory which will be used to run the IDE. :: Try (in order): ANDROID_STUDIO_JDK, ..\jre, JDK_HOME, JAVA_HOME.

As explained above, I picked the ..\jre option.如上所述,我选择了..\jre选项。

Today I found another situation when this problem occures - when you have several JDK, defined in JAVA_PATH.今天我发现了另一个出现这个问题的情况——当你有多个JDK,定义在JAVA_PATH中。 I have:我有:

JAVA_HOME = C:\JAVA\JDK\jdk1.6.0_38;C:\JAVA\JDK\jdk1.7.0_10

So I received this problem with Android Studio setup所以我收到了 Android Studio 设置的这个问题

But when I've removed one of JDK - problem has been solved:但是,当我删除了其中一个 JDK - 问题已解决:

JAVA_HOME = C:\JAVA\JDK\jdk1.7.0_10

Installation wisard found my jdk and i had a nice night to study studio.安装向导找到了我的 jdk,我度过了一个愉快的夜晚学习工作室。

But unfortunatelly even installed studio doesn't work with several jdk.但不幸的是,即使安装的工作室也不能与几个 jdk 一起使用。 Does anybody know how to fix it?有人知道如何解决吗?

I hope I've helped someone我希望我帮助了某人

MAKE SURE YOU RESTART ANDROID STUDIO确保您重新启动 ANDROID STUDIO

Even though I should know better and swear I did, make sure you restart studio after making these changes as it clearly does not check them on every build (which to me makes sense that system/user variables should only be read once on startup)即使我应该知道更好并且发誓我做到了,请确保在进行这些更改后重新启动工作室,因为它显然不会在每次构建时检查它们(对我来说,系统/用户变量应该只在启动时读取一次)

Anyway, yea... Make sure you restart after you make these changes.无论如何,是的...确保在进行这些更改后重新启动。

Path = to the bin folder in the jdk folder (path already exists)路径= 到 jdk 文件夹中的 bin 文件夹(路径已存在)

JAVA_HOME = to the jdk folder JAVA_HOME = 到 jdk 文件夹

Windows 64 bit, JDK 64 bit (Solution that worked for me) Tried all the above solutions, and None of them worked, I have been trying to solve it for the past few days and now I did it successfully. Windows 64 位,JDK 64 位(对我有用的解决方案)尝试了上述所有解决方案,但都没有奏效,过去几天我一直在尝试解决它,现在我成功解决了。 For me the problem was when I first installed Android Studio my JDK version was 1.7, then after installing I updated the JDK to 1.8, then I removed the old JDK folder and everything was messed up, even uninstalling and reinstalling android studio randomly didn't solve the issue.对我来说,问题是当我第一次安装 Android Studio 时,我的 JDK 版本是 1.7,然后安装后我将 JDK 更新到 1.8,然后我删除了旧的 JDK 文件夹,一切都搞砸了,甚至随机卸载并重新安装 android studio 也没有解决问题。

Below is the solution that worked for me以下是对我有用的解决方案

  1. Uninstall Android Studio.卸载 Android Studio。

  2. clean temp files and android studio C:\Users\Username.AndroidStudio1.5清理临时文件和 android studio C:\Users\Username.AndroidStudio1.5

  3. Uninstall JDK.卸载 JDK。

  4. Now without JDK try to install Android Studio and now it will show the message that it can't find any JDK.现在在没有 JDK 的情况下尝试安装 Android Studio,现在它会显示找不到任何 JDK 的消息。 Stop installation停止安装

  5. Install JDK 1.7 or 1.8 (Set JAVA_HOME, JDK_HOME, path Environment variables as explained by everybody above)安装 JDK 1.7 或 1.8(设置 JAVA_HOME、JDK_HOME、path 环境变量如上所述)

  6. Install Android Studio.安装安卓工作室。

  7. Done.完毕。 Enjoy and happy coding.享受和快乐的编码。

  1. Add JAVA_HOME and JDK_HOME system environment variables.添加 JAVA_HOME 和 JDK_HOME 系统环境变量。
  2. Right-click android studio (the 64 version if that's your OS and JDK) and go to compatibility tab and set "Run as administrator" to true.右键单击android studio(如果是您的操作系统和JDK,则为64版本)并转到兼容性选项卡并将“以管理员身份运行”设置为true。
  3. Run android studio and high-five me virtually when it works.运行 android studio 和 high-5 me 时虚拟运行。
  4. If that fails, try "where java" in cmd.exe.如果失败,请在 cmd.exe 中尝试“where java”。 If it lists c:\system32\java.exe first, then rename the file and try again.如果它首先列出 c:\system32\java.exe,则重命名该文件并重试。

Install the latest JDK in your system from JDK 7 and JRE 7 Installation Guide .JDK 7 和 JRE 7 安装指南在您的系统中安装最新的JDK

JAVA_HOME -> C:\Program Files\Java\jdk1.7.0_4
path -> C:\Program Files\Java\jdk1.7.0_4\bin

In my experience, I was unable (even after adding JDK_HOME) to launch Studio via either the shortcut or studio.exe itself.根据我的经验,我无法(即使在添加 JDK_HOME 之后)通过快捷方式或 studio.exe 本身启动 Studio。 I had to first run bin/studio.bat (mentioned in the original question).我必须先运行 bin/studio.bat (在原始问题中提到)。 After the first successful launch, I'm able to start it with the shortcut.第一次成功启动后,我可以使用快捷方式启动它。

If setting the JAVA_HOME variable doesn't work for you, set:如果设置JAVA_HOME变量对您不起作用,请设置:

STUDIO_JDK=C:\Progra~1\Java\jdk1.8.0_172

Where the path points to your JDK installation This is the only thing which works for me in Windows 32bit with Android 10 and up.路径指向您的 JDK 安装的位置 这是唯一适用于我的 Windows 32 位和 Android 10 及更高版本的东西。

If you have a 64 bit windows OS, pointing the JAVA_HOME system variable to如果您有 64 位 Windows 操作系统,请将 JAVA_HOME 系统变量指向

C:\Program Files (x86)\Java\jdk1.7.0_21

Will work when什么时候可以工作

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

fails to work.无法工作。

You need 1.7 JDK installed on your system.您需要在系统上安装 1.7 JDK。 Add a system variable with:添加一个系统变量:

TRY TO INSTALL 32BIT JDK尝试安装 32 位 JDK

if you have jdk installed and had set up the System Varibles such as JAVA_HOME or JDK_HOME and tried click back and then next ,you might have installed the 64bit JDK,just download the 32bit jdk and install it.如果您安装了 jdk 并设置了系统变量,例如 JAVA_HOME 或 JDK_HOME 并尝试单击返回然后下一步,则您可能安装了 64 位 JDK,只需下载 32 位 jdk 并安装即可。

I downloaded the latest jdk version我下载了最新的jdk版本

JAVA_HOME to C:\Program Files\Java\jdk1.8.0_11\bin Set the PATH to C:\Program Files\Java\jdk1.8.0_11\bin JAVA_HOME 到 C:\Program Files\Java\jdk1.8.0_11\bin 将 PATH 设置为 C:\Program Files\Java\jdk1.8.0_11\bin

I restarted the STUDIO and it worked.我重新启动了 STUDIO,它工作了。

在 Windows 10 上,重新启动安装程序并以管理员身份运行对我有用。

To complete this stack of possible solutions: For me the problem was, that I did not execute the Android-Studio-Setup as administrator.完成这一系列可能的解决方案:对我来说,问题是我没有以管理员身份执行 Android-Studio-Setup。 Running it as administrator then made me able to install Android-Studio.以管理员身份运行它然后让我能够安装 Android-Studio。

For me, the problem was that I had changed the GC vm arg to -XX:+UseParallelGC in the C:\Users\<username>\.AndroidStudio2.1\studio64.exe.vmoptions file.对我来说,问题是我在C:\Users\<username>\.AndroidStudio2.1\studio64.exe.vmoptions文件中将 GC vm arg 更改为-XX:+UseParallelGC That's what I use in Eclipse and I was trying various things to get AndroidStudio half way as efficent as Eclipse.这就是我在 Eclipse 中使用的东西,我正在尝试各种方法来让 AndroidStudio 的效率达到 Eclipse 的一半。 I restored the GC to -XX:+UseConcMarkSweepGC .我将 GC 恢复为-XX:+UseConcMarkSweepGC

原始问题的答案是,可能是您从 android studio 的 32 位快捷方式图标打开 android studio,尝试从安装 android studio 设置的 .../bin/ 下的图标“studio64”打开。

In case you had it running but Now it doesn't Launch.如果你让它运行但现在它没有启动。
I deleted the C:\Users\<NAME>\.AndroidStudio<version>\ folder and it worked.我删除了C:\Users\<NAME>\.AndroidStudio<version>\文件夹,它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM