How to fix “Error - Failed to execute tools\android.bat, error 2 ” in Android?

后端 未结 13 1519
死守一世寂寞
死守一世寂寞 2020-12-17 10:28

When i click on AVD Manager, i am getting an error as in the screenshot below.

Referred to the following links. But none of the solution works for me.

Failed

相关标签:
13条回答
  • 2020-12-17 10:28

    Please check your COMSPEC environment variable (intuitive, I know).

    There are apparently some programs that modify this, which in turn break these Android tools (and presumably other programs that rely on .bat files as well).

    To check this, in a command window, type

    echo %COMSPEC%

    The resulting value should probably be C:\Windows\System32\cmd.exe

    If you have multiple exes jammed in there, or if the variable ends with a semicolon, you've got a broken COMSPEC variable. If so, please edit your system's environment variables and fix it, setting it to the cmd.exe path above.

    0 讨论(0)
  • 2020-12-17 10:30

    I have a x86 system (not x86_64).

    in tools\lib\find_jave.bat I replaced:

      find /i "x86" > NUL && set arch_ext=32 || set arch_ext=64
    

    With:

      rem find /i "x86" > NUL && set arch_ext=32 || set arch_ext=64
      set arch_ext=32
    

    Then when android.bat runs, it prints:

      The system cannot find the file specified.
    

    Yet it DOES run the SDK manager.

    I suspect the 'find' line is broken. If you have a 64 bit system, try setting arch_ext to 64 and test that.

    0 讨论(0)
  • 2020-12-17 10:33

    In my case.Android root folder was readonly. -->Remove readonly tick

    0 讨论(0)
  • 2020-12-17 10:34

    It needs to copy those " SDK Manager.exe " and "AVD Manager.exe" to the SDK root folder, I needed to copy them to C:\android-sdk\ form Lib Folder, this is because, SDK Manager.exe and AVD Manager.exe are looking for tools

    0 讨论(0)
  • 2020-12-17 10:36

    Modifying this file [SDK HOME]\tools\android.bat

    rem Check we have a valid Java.exe in the path.
    set java_exe= JAVA PATH\jre7\bin\java.exe
    

    * JAVA PATH is in your java sdk folder

    and delete these two lines:

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

    more here: Issue 42896: SDK Manager fails to open

    0 讨论(0)
  • 2020-12-17 10:37

    My android.bat file was missing when updating the particular SDK package and my computer suddenly shut down. Thus, my tools folder became empty.

    enter image description here

    You can recover your android.bat file from temp folder

    enter image description here

    1. Manually unzip tools_r23.05-windows or any tool_rXX.zip file (red color)

    2. Get a folder called tools (orange color)

    3. Copy all the file in this folder to the original tools folder (outside temp folder, e.g. D:\android-sdk\tools)

    In my case, the problem was solved this way. Hope this helps.

    0 讨论(0)
提交回复
热议问题