Windows 7上的Android Studio安装失败,未找到JDK

在Windows 7上安装Android Studio时,启动应用出现找不到JDK的错误。解决方法包括检查环境变量,确保不包含路径中的非法字符,更新或设置正确的JDK路径,以及在Android Studio安装目录的bin文件夹内直接运行studio.bat来识别错误。
摘要由CSDN通过智能技术生成

本文翻译自: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的Windows 7 64位上运行。 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. 错误:无法启动Android Studio。 No JDK found. 找不到JDK。 Please validate either ANDROID_STUDIO_JDK, or JDK_HOME or JAVA_HOME points to valid JDK installation. 请验证ANDROID_STUDIO_JDK或JDK_HOME或JAVA_HOME指向有效的JDK安装。 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. 我希望你们中的一些人可以让我知道您是否能够安装它或遇到问题。


#1楼

参考:https://stackoom.com/question/17Xhd/Windows-上的Android-Studio安装失败-未找到JDK


#2楼

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为我工作。 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也设置在上述位置。


#3楼

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. 可能会发生此错误,因为您在path变量中引用了较旧的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 Studio安装中*Project Defaults* -> *Project Structure* -> Click "New" -> Select "Android SDK" -> Select the SDK文件夹。


#4楼

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已过时…”,请单击“ 配置 ”->“ 项目默认设置 ”->“ 项目结构 ”,选择“ SDK ”->“ Android SDK ”,然后在“ 构建目标 ”中选择“ Android 4.2.2 ”。 Click "OK". 点击“确定”。 Now it should work fine. 现在应该可以正常工作了。


#5楼

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

#6楼

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. 因此,我将其卸载并重新安装到程序文件中,现在可以正常启动了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值