Android SDK和AVD Manager无法运行

lop*_*d98 9 android android-virtual-device

我安装了Android SDK,但我无法使用它,因为AVD和SDK Manager无法运行.当我尝试打开其中任何一个时,命令提示符窗口会弹出大约半秒钟然后关闭.我已经尝试从命令提示符运行exe来查看是否有错误消息,但没有输出,它的行为相同.我研究了这个问题,发现其他计算机完全一样.我尝试了一些贴在那里的解决方案:

解决方案似乎不起作用

  • 将JDK位置添加到PATH环境变量的开头
  • 将Android SDK位置添加到PATH环境变量中
  • 以管理员身份运行应用程序
  • .android从user(C:/Users/[User Name])目录中删除该文件夹
  • 安装在C:驱动器的根目录中,而不是在Program Files中

操作系统信息:Windows 7家庭高级版,管理员权限


更新

我想我找到了问题的根源,但我仍然不知道如何修复它.问题似乎与我android.batC:\Android\android-sdk\tools目录中的文件有关.它试图调用find_java.bat但由于语法问题很小而无法调用.这是输出:


'C:\ Android\ANDROI~1\tools\lib\find_java.exe -s'未被识别为内部或外部命令,可运行程序或批处理文件.

错误:找不到合适的Java.为了正确使用Android Developer Tools,您需要在系统上安装合适的Java JDK版本.我们建议您安装JDK版本的JavaSE,可在此处获取:http: //www.oracle.com/technetwork/java/javase/downloads

您可以在此处找到完整的Android SDK要求:http: //developer.android.com/sdk/requirements.html


经过一些修改后android.bat,我能够调用find_java.bat它,无论我做了什么,它都会产生一堆错误.我终于感到沮丧,并决定硬编码的位置java.exe.稍后在批处理文件中还有另一个错误.我开始认为我的安装或批处理文件确实存在问题.这是批处理文件(android.bat):

@echo off
rem Copyright (C) 2007 The Android Open Source Project
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem Useful links:
rem Command-line reference:
rem   http://technet.microsoft.com/en-us/library/bb490890.aspx

rem don't modify the caller's environment
setlocal

rem Set up prog to be the path of this script, including following symlinks,
rem and set up progdir to be the fully-qualified pathname of its directory.
set prog=%~f0

rem Grab current directory before we change it
set work_dir="%cd%"

rem Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0


rem Check we have a valid Java.exe in the path.
set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF

set jar_path=lib\sdkmanager.jar;lib\swtmenubar.jar

rem Set SWT.Jar path based on current architecture (x86 or x86_64)
for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a

:MkTempCopy
    rem Copy android.bat and its required libs to a temp dir.
    rem This avoids locking the tool dir in case the user is trying to update it.

    set tmp_dir=%TEMP%\temp-android-tool
    xcopy %swt_path% %tmp_dir%\%swt_path% /I /E /C /G /R /Y /Q > nul
    copy /B /D /Y lib\androidprefs.jar   %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\org.eclipse.*      %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\sdk*               %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\common.jar         %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\commons-compress*  %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\swtmenubar.jar     %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\commons-logging*   %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\commons-codec*     %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\httpclient*        %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\httpcore*          %tmp_dir%\lib\        > nul
    copy /B /D /Y lib\httpmime*          %tmp_dir%\lib\        > nul

    rem jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.
    set tools_dir=%cd%
    cd /d %tmp_dir%

:EndTempCopy

rem The global ANDROID_SWT always override the SWT.Jar path
if defined ANDROID_SWT set swt_path=%ANDROID_SWT%

if exist %swt_path% goto SetPath
    echo ERROR: SWT folder '%swt_path%' does not exist.
    echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
    goto :EOF

:SetPath
rem Finally exec the java program and end here.
REM set REMOTE_DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
call %java_exe% %REMOTE_DEBUG% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir=%work_dir% -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*

rem EOF
Run Code Online (Sandbox Code Playgroud)

更新(再次)

我在运行于virtualbox的WinXP上安装了Android SDK,它运行良好.我仍然宁愿能够在Win7上使用它.

小智 8

这就是我在Windows 8上工作的方式

  1. 添加JAVA_HOME环境变量并将其设置为java安装位置(即C:\Program Files (x86)\Java\jdk1.6.0_39\bin)

  2. 接下来编辑C:\ Users {YOUR USERNAME}\AppData\Local\Android\android-sdk\tools\android.bat找到该set java_exe= call lib\find_java.bat行并将其更改为 set java_exe=java.exe

  3. 保存文件,它应该运行

请注意,如果您收到有关swt位置的错误,只需对路径进行硬编码即可.将其设置为lib\x86或lib\x86_64

希望这可以帮助


小智 5

我安装了一个新的JD64版本的JDK,这解决了我的问题