Android SDK 管理器不会运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12686633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 11:26:37  来源:igfitidea点击:

Android SDK Manager will not run

androidsdk

提问by LBull

i'm on a Windows 7 Pro x64 with java jdk 7u7.

我使用的是带有 java jdk 7u7 的 Windows 7 Pro x64。

I try to install the Android SDK on my computer, but when i launch SDK Manager.exe, a dos-windows is opening and instantly closing. So i tried to launch tools/android.bat. But that didn't work, it say to me that :

我尝试在我的计算机上安装 Android SDK,但是当我启动SDK Manager.exe 时,一个 dos-windows 正在打开并立即关闭。所以我尝试启动tools/android.bat. 但这不起作用,它对我说:

"'C:\PROGRA~2\Android\ANDROI~1\tools\lib\find_java.exe -s' isn't a external or internal command ...

ERROR No suitable java such ..."

What i have do for fix error :

我为修复错误所做的工作:

  1. Install Java 6u35
  2. Install Java x32 and x64
  3. Check my path
  4. Launch in administrator
  5. Install in C:\Dev the sdk
  6. Install with android-sdk.zip or with android-sdk.exe
  7. Add android directory in path
  1. 安装 Java 6u35
  2. 安装 Java x32 和 x64
  3. 检查我的路径
  4. 在管理员中启动
  5. 在 C:\Dev 安装 sdk
  6. 使用 android-sdk.zip 或 android-sdk.exe 安装
  7. 在路径中添加android目录

But anyone of this try was successful. Someone can help me?

但这次尝试中的任何一个都成功了。有人可以帮助我吗?

回答by Dan Puza

There appear to be several ways to launch the SDK Manager:

似乎有几种方法可以启动 SDK Manager:

  1. SDK Manager.exein the root of the Android SDK.
  2. SDK Manager.exein sdk\tools\libof the Android SDK.
  3. Window -> Android SDK Managermenu in Eclipse
  4. android.batin sdk\toolsof the Android SDK.
  1. SDK Manager.exe在 Android SDK 的根目录中。
  2. SDK Manager.exesdk\tools\libAndroid SDK 中。
  3. Window -> Android SDK ManagerEclipse 中的菜单
  4. android.batsdk\toolsAndroid SDK 中。

In my case, it looks like android.batfails on the line:

在我的情况下,它看起来android.bat在线上失败了:

for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a

As far as what that line is doing... if I manually run: "[path_to_java]java" -jar lib\archquery.jar

至于那条线在做什么......如果我手动运行: "[path_to_java]java" -jar lib\archquery.jar

It successfully returns: x86_64

它成功返回: x86_64

But when the batch file runs that same command, I don't know why but it fails with the error message:

但是当批处理文件运行相同的命令时,我不知道为什么但它失败并显示错误消息:

Unable to access jarfile lib\archquery.jar

So the variable swt_pathgets set to an empty string. Everything breaks down from there.

所以变量swt_path被设置为一个空字符串。一切都从那里崩溃了。

The batch file sets the correct value for the variable java_exe. Others have commonly reported this as a problem, but those workarounds weren't relevant in my case.

批处理文件为变量设置了正确的值java_exe。其他人通常将此报告为一个问题,但这些解决方法与我的情况无关。

People have recommended commenting out the problem line by adding REM to the beginning of it, and adding a line to manually set the swt_pathvariable, which is a valid workaround:

人们建议通过在问题行的开头添加 REM 并添加一行来手动设置swt_path变量来注释掉问题行,这是一种有效的解决方法:

REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86

BUT, the critical issue in my case is that it's choosing to load a jar file from either the lib\x86or the lib\x86_64folder here. At some point, things were getting confused between the BAT file error, a 32-bit JDK, and a 64-bit Android SDK.

但是,就我而言,关键问题是它选择从此处的lib\x86lib\x86_64文件夹加载 jar 文件。在某些时候,BAT 文件错误、32 位 JDK 和 64 位 Android SDK 之间的事情变得混乱。

SO, the workaround in my case was to:

所以,在我的情况下的解决方法是:

  1. Uninstall ALL versions of Java
  2. Install the JDK
    • You can either use the 32-bit Android SDK and install the 32-bit JDK
    • Or use the 64-bit Android SDK and install the 64-bit JDK
    • But the "bitness" of the JDK should match the Android SDK. It appears that either of the 32-bit or the 64-bit will work on a 64-bit computer, AS LONG AS the JDK bitness matches the Android SDK bitness.
  3. Edit "android.bat"

    • If using the 32-bit Android SDK/JDK, use lib\x86:

      REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
      set swt_path=lib\x86
      
    • If using the 64-bit Android SDK/JDK, use lib\x86_64:

      REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
      set swt_path=lib\x86_64
      
  1. 卸载所有版本的 Java
  2. 安装 JDK
    • 您可以使用 32 位 Android SDK 并安装 32 位 JDK
    • 或者使用64位Android SDK并安装64位JDK
    • 但是JDK的“位数”应该与Android SDK相匹配。似乎 32 位或 64 位都可以在 64 位计算机上运行,​​只要 JDK 位数与 Android SDK 位数匹配。
  3. 编辑“android.bat”

    • 如果使用 32 位 Android SDK/JDK,请使用lib\x86

      REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
      set swt_path=lib\x86
      
    • 如果使用 64 位 Android SDK/JDK,请使用lib\x86_64

      REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
      set swt_path=lib\x86_64
      

After doing this, I can successfully run the SDK Manager by running android.bat, or from the Eclipse menu (but still not by running either of the SDK Manager.exefiles directly).

执行此操作后,我可以通过运行android.bat或从 Eclipse 菜单成功运行 SDK 管理器(但仍不能通过SDK Manager.exe直接运行任一文件)。

回答by mikegonzalez2k

I had this answer just this week and have determined what is causing it.

本周我刚刚得到了这个答案,并确定了导致它的原因。

When Java updates it changes the path where the executable files are stored. This means that when the SDK manager goes to look up javaw.exe it cannot find it and instantly closes.

当 Java 更新时,它会更改存储可执行文件的路径。这意味着当 SDK 管理器查找 javaw.exe 时,它​​找不到它并立即关闭。

Therefore re-installing the Android SDK will NOT solve the problem. Neither will re-installing JAVA.

因此重新安装 Android SDK 并不能解决问题。也不会重新安装JAVA。

The only way to solve this problem is to correctly point to the location where JAVA is stored.

解决这个问题的唯一办法就是正确指向JAVA的存放位置。

Windows has a way of doing this called an Environmental Variable. There is a variable called PATH which stores all the directories where Windows will look for executable files.

Windows 有一种称为环境变量的方法。有一个名为 PATH 的变量,它存储 Windows 将在其中查找可执行文件的所有目录。

Thus you have to to modify that PATH variable to include a path to JAVA. By default JDK 7 has the following path:

因此,您必须修改该 PATH 变量以包含 JAVA 的路径。默认情况下,JDK 7 具有以下路径:

C:\Program Files\Java\jdk1.7.0_10\bin

To edit your Environmental Variables do the following.

要编辑您的环境变量,请执行以下操作。

From the Start Menu right click on Computer and select "Properties"
This will take you to the Control Panel System Menu
On the left column look for the option "Advanced System Settings"
This will open a System Properties window
One of the tabs is named Advanced
In that there is a button that says Environmental Variables
If you search your System Variables you will see one called "Path"
Edit that variable and add the path above to include the latest Java Path.

Once you are done the SDK Manager should immediately be able to open up and you can continue updating to the latest revision of the Android SDK.

完成后,SDK 管理器应该可以立即打开,您可以继续更新到 Android SDK 的最新版本。

Once the updates complete don't forget to make sure your IDE (ie Eclipse) is pointing to the correct location where the SDK is stored so that it reads the latest Android SDK files. To access this setting in Eclipse, go to Window -> Preferences -> Android

更新完成后,不要忘记确保您的 IDE(即 Eclipse)指向存储 SDK 的正确位置,以便它读取最新的 Android SDK 文件。要在 Eclipse 中访问此设置,请转到 Window -> Preferences -> Android

This will allow you to manually set the path where the SDK is stored.

这将允许您手动设置存储 SDK 的路径。

回答by Analizer

The only thing that helped me was reinstalling java into a path that did not contain any spaces, so instead of C:/Program Files to C:/Java and change the Path variable to the new value.

唯一帮助我的是将 java 重新安装到不包含任何空格的路径中,因此将 C:/Program Files 改为 C:/Java 并将 Path 变量更改为新值。

Hope this helps.

希望这可以帮助。

回答by ViRuSTriNiTy

I had the same issue and it's most likely caused by spaces in the path names. It's known that spaces in path names and batch files don't combine well together.

我遇到了同样的问题,很可能是由路径名中的空格引起的。众所周知,路径名和批处理文件中的空格不能很好地结合在一起。

You can verify that by opening a command line prompt, changing the location to %SDK%\tools\lib and running find_java.bat. You will get an batch error like

您可以通过打开命令行提示符,将位置更改为 %SDK%\tools\lib 并运行 find_java.bat 来验证这一点。你会得到一个批处理错误,比如

'C:\PROGRA~2\Android\Android' is not recognized as an internal or external command, 
operable program or batch file.

Just install the SDK into C:\Android\SDK and the NDK into C:\Android\NDK and it will work.

只需将 SDK 安装到 C:\Android\SDK 并将 NDK 安装到 C:\Android\NDK 即可。

回答by benaich

This is how I finally fix it open tools/android.bat

这就是我最终修复它的方法 打开工具/android.bat

set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF

replace it with your java path

用你的java路径替换它

set java_exe="c:\PROGRA~1\Java\jdk1.7.0\bin\java.exe" 

Note:Do not use C:\Program Files\Somethingit throw an error because of the space use the short name notation C:\PROGRA~1\Something

注意:不要使用C:\Program Files\Something它会抛出错误,因为空格使用短名称表示法 C:\PROGRA~1\Something

and it will work like charm

它会像魅力一样工作

回答by Simon Sanderson

Same issue for me SDK Manager.exejust stopping with no error message or windows event.

对我来说同样的问题SDK Manager.exe只是在没有错误消息或 Windows 事件的情况下停止。

I fixed this with a hybrid of the already provided answers (I'm running on Win 8.1). The problem appears to be that the java.exe targeted by find_javawas out-of-step with the recently installed JDK version.

我用已经提供的答案的混合解决了这个问题(我在 Win 8.1 上运行)。问题似乎是find_java所针对的 java.exe与最近安装的 JDK 版本不一致

for me:

为了我:

  • <sdk>was C:\Users\Simon\AppData\Local\Android\sdk
  • <jdk>was C:\PROGRA~1\Java\jdk1.7.0_80\bin

    1. I added my JDK install path to the PATH environment variable e.g. ...;C:\PROGRA~1\Java\jdk1.7.0_80\bin;...
    2. After opening a new command window and running find_java.batin the <sdk>\tools\lib\folder I noticed that the java_exeenv variable was set was to C:\Windows\System32\java.exewhich was not what I expected.
    3. I deleted (well renamed) the java.exein C:\Windows\System32
    4. I ran find_java.batagain and now the java_exeenv variable was set to java_exe=<jdk>\java.exeas expected.
    5. Then in <sdk>I could run SDK Manager.exesuccessfully.
  • <sdk>C:\Users\Simon\AppData\Local\Android\sdk
  • <jdk>C:\PROGRA~1\Java\jdk1.7.0_80\bin

    1. 我将我的 JDK 安装路径添加到 PATH 环境变量中,例如 ...; C:\PROGRA~1\Java\jdk1.7.0_80\bin; ...
    2. 在打开一个新的命令窗口并在文件夹中运行find_java.bat后,<sdk>\tools\lib\我注意到java_exeenv 变量设置为C:\Windows\System32\java.exe这不是我所期望的。
    3. 我删除(以及重命名)的java.exe的C:\ Windows \ System32下
    4. 我再次运行find_java.bat,现在java_exeenv 变量已java_exe=<jdk>\java.exe按预期设置。
    5. 然后在<sdk>我可以成功运行SDK Manager.exe

回答by Tai Li

Changing the JAVA_HOME from existing pointing to a JDK path to a JRE path works for me.

将 JAVA_HOME 从现有指向 JDK 路径更改为 JRE 路径对我有用。