Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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.

like image 811
Prem Avatar asked Dec 26 '13 05:12

Prem


3 Answers

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.

like image 161
yean Avatar answered Oct 31 '22 13:10

yean


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.

like image 8
d9n Avatar answered Oct 31 '22 13:10

d9n


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.

like image 2
Sulung Nugroho Avatar answered Oct 31 '22 11:10

Sulung Nugroho