How To Fix "error - Failed To Execute Tools\android.bat, Error 2 " In Android?
Solution 1:
My android.bat
file was missing when updating the particular SDK package and my computer suddenly shut down. Thus, my tools folder became empty.
You can recover your android.bat
file from temp folder
Manually unzip tools_r23.05-windows or any tool_rXX.zip file (red color)
Get a folder called tools (orange color)
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.
Solution 2:
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.
Solution 3:
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.
Solution 4:
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:
calllib\find_java.bat
ifnot defined java_exe goto :EOF
more here: Issue 42896: SDK Manager fails to open
Solution 5:
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.
Post a Comment for "How To Fix "error - Failed To Execute Tools\android.bat, Error 2 " In Android?"