简体   繁体   English

尝试启动 Android Studio 时出现 JDK 错误

[英]JDK error when trying to start Android Studio

I have just switched from Windows7 to Windows8.1 and I'm having trouble making Android Studio work now.我刚刚从 Windows7 切换到 Windows8.1,我无法让 Android Studio 现在工作。

I have installed Android Studio and the JDK.我已经安装了 Android Studio 和 JDK。 First I tried it out with the latest versions Android Studio v.0.8.14 and JDK 1.8 , but I could not get it to work.首先,我使用最新版本的 Android Studio v.0.8.14和 JDK 1.8进行了尝试,但我无法让它工作。 I then tried to use the versions I used on my previous Windows7, and installed Android Studio 0.8.2 and JDK 1.7.0_67 , but I still can't get it to work.然后我尝试使用我在以前的 Windows7 上使用的版本,并安装了 Android Studio 0.8.2和 JDK 1.7.0_67 ,但我仍然无法让它工作。

The error I'm getting is:我得到的错误是:

Failed to load JVM DLL C:\Program Files\Java\jdk1.7.0_67\jre.加载失败If you already have a 64-bit JDK installed, define JAVA_HOME variable in Computer > System Properties > System Settings > Environment Variables如果您已经安装了 64 位 JDK,请在计算机 > 系统属性 > 系统设置 > 环境变量中定义 JAVA_HOME 变量

I have set JAVA_HOME to my JDK path.我已将JAVA_HOME为我的 JDK 路径。 I've tried to add \bin to that path, which didn't help.我试图将\bin添加到该路径,但没有帮助。 I've tried to add the JDK_HOME variable and set path to it, which didn't help either.我尝试添加JDK_HOME变量并为其设置路径,但这也无济于事。 I have also added "C:\Program Files\Java\jdk1.7.0_67\" to my PATH variable, which also didn't help.我还在我的 PATH 变量中添加了"C:\Program Files\Java\jdk1.7.0_67\" ,这也没有帮助。 I tried editing studio.bat adding a string to point to my JDK folder, which also didn't work.我尝试编辑studio.bat添加一个字符串以指向我的 JDK 文件夹,这不起作用。

When I check my Java from console ( cmd ) I get the msg that it works find:当我从控制台( cmd )检查我的 Java 时,我得到了它工作的消息:

C:\Users\Igor>java -version java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode) C:\Users\Igor>java -version java version "1.7.0_67" Java(TM) SE Runtime Environment (build 1.7.0_67-b01) Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode )

Is Windows 8.1 the problem? Windows 8.1 是问题吗? Do I have to do something different on it?我必须对它做一些不同的事情吗?

I had exactly the similar problem: 我有完全类似的问题:

failed to create JVM: error code -6 
JVM PATH: .............
If you already have a 64-bit JDK installed, define a JAVA_HOME variable in Computer > System Properties > System Settings> Environment Variables. 
Note: Do *not* choose a Java "JRE". You need to point to a full JDK, otherwise the IDE may fail to start. See http://tools.android.com/knownissues for more details.


Solution for me 我的解决方案

I solved it with the help of Rahul Wadhai : 我在Rahul Wadhai的帮助下解决了这个问题

1) Go to C:\\users\\<your_user>.AndroidStudio2.2\\ and open studio.vmoptions 1)转到C:\\users\\<your_user>.AndroidStudio2.2\\并打开studio.vmoptions

2) change -Xmx and XX:MaxPermSize to lower values(then you have currently) and try to run AS again. 2)将-XmxXX:MaxPermSize更改为较低的值(然后是当前值),然后尝试再次运行AS ( If it does, then you can increase the values back. ) (如果是这样,则可以将值增加回来。)

3) If it doesnt help, then try to rename .AndroidStudioX.X and then open AS again. 3)如果没有帮助,请尝试重命名.AndroidStudioX.X ,然后再次打开AS

4) If it doesnt help, then you can search the problem within this android folder (using TextCrawler) , maybe somewhere in config files, there needed to change something. 4)如果没有帮助,那么您可以在此android文件夹(使用TextCrawler)中搜索问题,可能在配置文件中的某个位置,需要进行一些更改。 And then you can import settings from old folder. 然后,您可以从旧文件夹中导入设置。

您必须在PATH变量的名为JAVA_HOME = "C:\\Program Files\\Java\\jdk1.7.0_67"的系统变量中创建一个新变量。

To get this working, I put my JDK path in the Path variable as the first item. 为了使此工作正常进行,我将JDK路径放在Path变量中作为第一项。 For some reason, when it's the last item it does not work. 由于某种原因,当它是最后一个项目时,它将不起作用。

You need to mention the JDK folder path in the Environment variable: 您需要在Environment变量中提及JDK文件夹路径:

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_51

Don't use build number coming in cmd . 不要使用cmd版本号。

Follow these steps: 跟着这些步骤:

Control Panel>>System>>Advanced(tab)>>Environment Variables>>System Variables
New
 Variable name: _JAVA_OPTIONS
 Variable value: -Xmx512M

I tweaked the studio.vmoptions file when I followed a method in making it run faster and it stopped working showing the same JDK error.. I did most of the fix mentioned above and none worked for me. 当我遵循一种使它运行更快的方法并停止工作以显示相同的JDK错误时,我对studio.vmoptions文件进行了调整。.我做了上面提到的大多数修复,但没有一个对我有用。 What worked for me though was deleting the studio.vmoptions file and everything was great again. 不过,对我有用的是删除studio.vmoptions文件,一切再次变得不错。

Go to your c:\\ users\\yourcomputername\\ for example .AndroidStudio1.5 You will see config and system folder in it then delete the .AndroidStudio1.5 using it as example . 例如,转到您的c:\\ users \\ yourcomputername \\。AndroidStudio1.5您将在其中看到config和system文件夹,然后以.AndroidStudio1.5为例删除它。 Go and relaunch the studio64 去重新启动工作室64

which worked for me after many frustrated attempts:经过多次沮丧的尝试后,这对我有用:

go to the folder C:\program files\Android\Android Studio\bin go 到文件夹 C:\program files\Android\Android Studio\bin

rename the file 'studio.64' to 'studio.bat' and run this file.将文件“studio.64”重命名为“studio.bat”并运行该文件。

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

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