18

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 to execute tools\android.bat: solution

Android SDK Windows Failed to execute Android.bat

https://android.stackexchange.com/questions/33538/android-sdk-cant-find-android-bat

In Tools -> Lib Folder i have my AVD Manager.

In Tools -> i have android.bat

I tried the following options and it did not work.

  1. Copied Android SDK Manager in Lib folder and clicked on AVD Manager. Got the same error.
  2. Copied AVD Manager to Tools folder and clicked AVD Manager. Got the same error.

Please find below the error screenshot.

enter image description here

Kindly let me know if any thoughts.

Community
  • 1
  • 1
Prem
  • 4,823
  • 4
  • 31
  • 63
  • http://stackoverflow.com/questions/16753240/avd-manager-cant-find-tools-android-bat-even-though-its-there?rq=1 maybe –  Dec 26 '13 at 06:35
  • got the same crappy message. Lame android developers, damn... – tmporaries Dec 08 '14 at 19:25

13 Answers13

56

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.

Mahm00d
  • 3,881
  • 8
  • 44
  • 83
yean
  • 1,307
  • 12
  • 8
  • Awsome! Might have got corrupted when my update stopped midway. Thanks @yean – Dhinakaran Thennarasu Mar 04 '15 at 01:14
  • Thanks. This happened to me with Visual Studio 2015 Preview and Tools for Apache Cordova. – Ricky65 Apr 23 '15 at 01:06
  • Thanks. Solved my problem. This happened while updating android studio and my laptop shut down suddenly. – Umesh Jun 02 '15 at 18:13
  • Worked for me too. Thanks.. ! – iMDroid Oct 05 '15 at 08:46
  • If you don't have these zipfiles like in my case I suggest [reinstalling SDK tools](http://developer.android.com/sdk/index.html) instead of manually adding tool directories. – A1rPun Dec 02 '15 at 08:55
  • I have to do this procedure whenever attempting to update tools. I get a 'can't move folder' error message then lose all tools after update attempt. I had to do the same thing after each tools update attempt in eclipse. – Androidcoder Sep 15 '16 at 22:56
  • A similar solution given years ago for eclipse eventually got hundreds of up votes, nice work. – Androidcoder Sep 15 '16 at 23:04
8

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.

d9n
  • 404
  • 5
  • 7
2

I got the same problem and I found where it's come from. I know it's a 2 year question, but the problem still remain the same for some people.

Cannot run program "C:\Users\Hp\AppData\Local\Android\Sdk\tools\android.bat

It will happen when we re-install android studio for some reasons. I even re-installed it 4 times. Problem came at the first time I re-installed. I tried to re-install again and again but the problem remain the same.

Finally I open C:\Users\Hp\AppData that actually hidden. And in the next folder \local\Android\Sdk, now I found some folder Sdk, Sdk1, Sdk2, and Sdk3.

Now I remember, as I re-installed it 4 times, that's why I have four folders. I remove ( not actually remove, but rename it with additional XX at the end of folder name) Sdk folder and change Sdk3 to Sdk. Now everything is working fine.

Why? because my last re-install create Sdk3 folder that contain android.bat required for the main program where no more exist in the first Sdk folder.

Before I got this as well :

Error:Execution failed for task ':app:compileDebugAidl'. > java.lang.IllegalStateException: aidl is missing

And now it's missing and the problem is solved.

If you happen got the same problem with me. hope it could help you.

Sulung Nugroho
  • 1,605
  • 19
  • 14
0

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

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
0

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.

Doug
  • 1
0

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

0

I had this problem and downloaded tools_r25.2.3-windows.zip file. I think this problem caused on updating tools. I deleted tools to update but this error occured when I installed. Be careful updating.

ddagsan
  • 1,786
  • 18
  • 21
0

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

  • This question was answered 3 years ago. What value does your answer bring? – Maciej Jureczko Sep 23 '17 at 11:51
  • Please update your answer to explain how this improves on the other accepted and upvoted answers this question already has. Also, this question is 4 years old, your efforts would be more appreciated by users who have recent unanswered questions. Please review [How do I write a good answer](https://stackoverflow.com/help/how-to-answer). – FluffyKitten Sep 23 '17 at 11:59
0

My situation: Right after installing Android support into Visual Studio, the "Open Android Emulator Manager (AVD)" button was broken and running C:\Program Files (x86)\Android\android-sdk\tools\lib\AVD Manager.exe produces the error shown by the OP. The screenshot in yean's answer shows an android-sdk folder that contains AVD Manager.exe, but my android-sdk folder did not contain any files (only folders).

Crazy as it sounds, simply copying AVD Manager.exe from android-sdk\tools\lib to android-sdk fixes both problems. (I couldn't create an API-18 arm emulator but API-19 worked.)

Qwertie
  • 16,354
  • 20
  • 105
  • 148
0

This wasn't working for me as I did not have this bat file nor the tools directory at all. And my temp directory did not have any zipped tools directory, so could not just replace.

MS suggested doing repair install

  1. Open the Windows Programs and Features Control Panel.
  2. Right click the relevant Microsoft Visual Studio entry, and select Change
  3. Click the Repair button in the Visual Studio dialog that opens.

That resolved my issue

cd491415
  • 823
  • 2
  • 14
  • 33
0

Happened several times on my environment. @Mahmood and @Qwertie solutions did help, until today.

Banged my head the whole afternoon searching & trying many solutions... finally this one unlocked the situation:

Remove hidden directory C:\Users\{yourUserName}\.android

Maxime Pacary
  • 22,336
  • 11
  • 85
  • 113
-2

Please copy the AVD Manager. Exe to the SDK Manager. Exe's directory which is the root directory of the SDK.

zhenghuiyan
  • 324
  • 4
  • 10
-2

Check that if the tools folder is missing in /sdk folder. If so, just unzip again from the zip package to the /sdk folder again. It works like charm for my case.

cheers.

i think it occurs when i accidentally hit delete packages button.

Alfred Loh
  • 87
  • 6