Android SDK and AVD Manager will not run - android

I installed the Android SDK but I cannot use it because the AVD and SDK Managers do not run. When I try to open either one of them, a command prompt window pops up for about a half a second and then closes. I have tried running the exe from the command prompt to see if there was an error message but there is no output and it acts the same. I researched the problem and found out that the exact same thing happens to other computers. I tried some of the solutions that were posted there:
Solutions that didn't seem to work
Adding the JDK location to the beginning of the PATH environment variable
Adding the Android SDK location to the PATH environment variable
Running the applications as an administrator
Deleting the .android folder from the user (C:/Users/[User Name]) directory
Installing in the root of the C: drive, instead of in Program Files
OS Info: Windows 7 Home Premium, Admin Privileges
Update
I think I found the source of the problem, but I still don't know how to fix it. The problem seems to be with my android.bat file in the C:\Android\android-sdk\tools directory. It tries to call find_java.bat but is unable to because of a small syntax problem. This is the output:
'C:\Android\ANDROI~1\tools\lib\find_java.exe -s' is not recognized as an internal or external command, operable program or batch file.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java JDK installed on your system.
We recommend that you install the JDK version of JavaSE, available here:
http://www.oracle.com/technetwork/java/javase/downloads
You can find the complete Android SDK requirements here:
http://developer.android.com/sdk/requirements.html
After some modifications to android.bat, I was able to get it to call find_java.bat, which in turn got a bunch of errors no matter what I did to it. I finally got frustrated and decided to hard-code in the location of java.exe. Later on in the batch file there was still another error. I am starting to think that something is really wrong with my installation or the batch file. This is the batch file (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
Update (again)
I installed the Android SDK on WinXP running in virtualbox and it works perfectly. I would still rather be able to use it on Win7 though.

This is how I got it to work on Windows 8
Add the JAVA_HOME environment variable and set it to your java
install location (i.e. C:\Program Files (x86)\Java\jdk1.6.0_39\bin)
Next edit C:\Users{YOUR
USERNAME}\AppData\Local\Android\android-sdk\tools\android.bat Find
the set java_exe= call lib\find_java.bat line and change it to
set java_exe=java.exe
Save the file and it should run
Note if you get an error about the swt location simply hardcode the path. Set it to lib\x86 or lib\x86_64
Hope this helps

I installed a new x64 version of the JDK and that fixed my issue

I had this problem with a fresh install of 64 bit win 7 pro, using and a fresh install of the 64 bit JDK.
Kenton Price's solution in this post fixed me up, and now it all works perfectly.
Android SDK installation doesn't find JDK
for some reason the (originally linux developed) ADK on my system needed JAVA_HOME defined with linux style forward slashes instead of windows style backslashes.

I found the same problem that Rajesh found from his comment above.
The command in parentheses on this line was not executing
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
Edit: some people may have this line:
for /f "delims=" %%a in ('"%~dps0find_java%arch_ext%.exe" -s') do set java_exe=%%a
This line is from find_java.bat in the tools\lib\ directory of the sdk.
I have a Win 7 x64 system and I'm not about to reload the entire OS so I hardcoded what MZB suggested from his post above:
After this line:
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
edit: or this line:
for /f "delims=" %%a in ('"%~dps0find_java%arch_ext%.exe" -s') do set java_exe=%%a
I added this line:
set java_exe=%JAVA_HOME%\bin\java.exe
This assumes you have the JAVA_HOME environment variable set to the Java JDK folder (without \bin)
If your JAVA_HOME variable includes the \bin then set it like this:
set java_exe=%JAVA_HOME%\java.exe
If you don't have the JAVA_HOME environment set, then you need to hard code it with the actual path you have on your machine as MZB did in his post.
I also did it for the javaw logic too:
set javaw_exe=%JAVA_HOME%\bin\javaw.exe
I can finally access the SDK Manager.
UPDATE 06/01/2015:
To Ken Y-N who updated this post after I submitted it:
When I created this post, I had referenced this line:
for /f "delims=" %%a in ('"%~dps0find_java%arch_ext%.exe" -s') do set java_exe=%%a
This in in my current find_java.bat from folder ...\sdk\tools\lib which I just updated yesterday from the current version of Android Studio Windows x64 version (android-studio-bundle-141.1903250-windows.exe). the variable %arch_ext% will either have 32 or 64 in it depending on what system they have.
But I don't know how the above line got converted to:
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
after Ken Y-N did the edit.
But perhaps some people have your version in their find_java.bat file but I would believe some people have the other like I do. I'm just pointing this out for those that are having a problem not being able to open their SDK Manager.
Plus I should mention I had this problem with both JDK1.7 and JDK1.8. I had originally installed JDK1.8 but when reading the requirements for Android Studio yesterday, it said JDK1.7 was required, so I installed JDK1.7 last night thinking that would solve my problem, but the problem with find_java.bat was the same with either version of JDK.
I should point out too, when I installed Android Studio with both versions of the JDK, I was originally able to access the SDK Manager before opening up Android Studio for the first time. But when I opened up Android Studio, it started updating the SDK Manager first and maybe that's when the problem occurs because after starting up an IDEA project, I could not open up the SDK Manager after that.
So maybe find_java.bat has this line BEFORE opening up Android Studio for the first time:
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
And when Adroid Studio updates the SDK, it the has this line?
for /f "delims=" %%a in ('"%~dps0find_java%arch_ext%.exe" -s') do set java_exe=%%a
I don't have time to test that out - I already lost so much time trying to figure out how to access the SDK. Maybe someone else can confirm this if they're having the same problem.

I also had same problem not able to open Android SDK manager, but by Deleting the .android folder from the user (C:/Users/[User Name]) directory it works...
Thanks

I just ran into a similar problem as lopsided98 had and tried all the solutions on here also and no results. then I remembered that I had to add an environment variable to locate java before i could get android studio to start in the first place so I just tried adding a new system variable for Android_home and directed it to my android folder C:\Program Files (x86)\Android . Just like I had done when setting up java and then it started up with no problems. SDK manager is also up and working now. I hope this helps, if you're still having problems
This was what i had found when setting up the java part and just thought I might give it a try for android too.
On some Windows systems, the launcher script does not find where Java is installed. If you encounter this problem, you need to set an environment variable indicating the correct location.
Select Start menu > Computer > System Properties > Advanced System
Properties.
Then open Advanced tab > Environment Variables and add a new system variable JAVA_HOME that points to your JDK folder, for example
C:\Program Files\Java\jdk1.7.0_21.

Dont delete the .android folder. Juz delete the avd folder within the .android folder. It shld do a lot of good to your work.
Advance cheers.
Prakash.

I had this issue and the problem turned out to be this:
D:\dev\adt-bundle-windows-x86_64-20130522\sdk>"tools\lib\find_java.exe"
C:\Windows\system32\java.exe
I vaguely recall ages ago having an issue with a program finding Java and copying it to the system32 directory to "resolve" it.
I removed those files and now:
D:\dev\adt-bundle-windows-x86_64-20130522\sdk>"tools\lib\find_java.exe"
C:\Program Files\Java\jre7\bin\java.exe
and SDK/ADK manager run properly now.

I had the same issue on my windows-8 64 bit machine. Narrowed the problem down to a
particular statement
for /f "delims=" %%a in ('"%~dps0\find_java.exe" -s') do set java_exe=%%a
in the find_java.bat file.
For some reason the statement in the parentheses was not being executed as a command.
I tried out all the suggested solutions above but none of them worked. In the end found that this particular statement worked fine on another Windows 8 64 bit machine so there was some problem with my Windows 8 installation. I checked my OS system files and found some of them were corrupt, so I did a repair of my Windows 8 installation and after that everything worked fine.

If the problem is on Windows machine, then just run the AVD Manager or the SDK Manager as Administrator

There may be an issue with \tools\lib\find_java.bat not successfully determining the location of the java.exe and javaw.exe executables.
The workaround here: http://www.gmansoft.com/android-sdk-manager-find-java-problem/
worked for me. Note that if you "fix" the problem in android.bat other batch files will still be broken.
In case the above link breaks, the workaround is to hardwire the results of find_java.bat to return the actual location of the java executables. e.g. edit it to be something like:
rem Check we have a valid Java.exe in the path. The return code will
rem be 0 if the command worked or 1 if the exec failed (program not found).
rem for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s') do set java_exe=%%a
set java_exe=c:\program files\Java\jdk1.8.0_25\bin\java.exe
if not defined java_exe goto :CheckFailed
:SearchJavaW
rem Check if we can find a javaw.exe at the same location than java.exe.
rem If that doesn't work, just fall back on the java.exe we just found.
rem for /f "delims=" %%a in ('"%~dps0\find_java%arch_ext%.exe" -s -w') do set javaw_exe=%%a
set javaw_exe=c:\program files\Java\jdk1.8.0_25\bin\javaw.exe
if not exist "%javaw_exe%" set javaw_exe=%java_exe%
goto :EOF

I faced the same issue when upgraded my working environment. The issue was in <AndroidSDK>\tools\lib\find_java.bat (thanx anyone who pointed to this file). It searched for 64-bit version of Java, while I had 32-bit version installed. Simple and dirty set arch_ext=32 in find_java.bat solved the issue for me.

I faced the same problem on Windows 8.1, and it is solved by running Android Studio as Administrator

Related

Unable to detect adb version when attempting to use uiautomatorviewer, no exit value

I am trying to use uiautomatorviewer to capture my Android device which is connected via usb.
I have uninstalled Android SDK and re-installed. I have no problems with adb commands such as install or connect etc. As you can see below, I am able to see the device attached with adb devices command and I am able to see the adb version when using adb version command. The problem is that when I launch uiautomatorviewer I run into
Unable to detect adb version, adb output:
At this point nothing else happens and the program does not connect to my device.
PS C:\Windows\system32> adb devices
List of devices attached
a2738481 device
PS C:\Windows\system32> adb version
Android Debug Bridge version 1.0.41
Version 30.0.3-6597393
Installed as C:\android-sdk\platform-tools\adb.exe
PS C:\Windows\system32> uiautomatorviewer
03:55:06 E/adb: Unable to detect adb version, adb output:
Terminate batch job (Y/N)? y
PS C:\Windows\system32>
Thinking possibly something is wrong with my uiautomatorviewer.bat file
#echo off
rem Copyright (C) 2012 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 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 Change current directory and drive to where the script is, to avoid
rem issues with directories containing whitespaces.
cd /d %~dp0
rem Get the CWD as a full path with short names only (without spaces)
for %%i in ("%cd%\..") do set prog_dir=%%~fsi
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
for /f %%a in ("%APP_HOME%\lib\uiautomatorviewer-26.0.0-dev.jar") do set jarfile=%%~nxa
set frameworkdir=.
if exist %frameworkdir%\%jarfile% goto JarFileOk
set frameworkdir=..\lib
if exist %frameworkdir%\%jarfile% goto JarFileOk
set frameworkdir=..\framework
:JarFileOk
set jarpath=%frameworkdir%\%jarfile%
if not defined ANDROID_SWT goto QueryArch
set swt_path=%ANDROID_SWT%
goto SwtDone
:QueryArch
for /f "delims=" %%a in ('%frameworkdir%\..\bin\archquery') do set swt_path=%frameworkdir%\%%a
:SwtDone
if exist "%swt_path%" goto SetPath
echo SWT folder '%swt_path%' does not exist.
echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
exit /B
:SetPath
set javaextdirs=%swt_path%;%frameworkdir%
call "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" "-Dcom.android.uiautomator.bindir=C:\android-sdk\tools" -jar %jarpath% %*
Note that when I run monitor.bat in C:\android-sdk\tools it works without any issues
-I removed and reinstalled Android SDK
-I tried previous older SDKs
-tried powershell and command prompt
-removing and adding path to environment variables
The only thing that finally fixed my issue was re installing windows.
But hey, at least now it works!

I can't run the Android SDK Manager through the Eclipse im getting an error in the Console window

This is the error/s im getting:
[2013-01-21 21:24:14 - SDK Manager] [SDK Manager] 'lib\find_java.bat' is not recognized as an internal or external command,
[2013-01-21 21:24:14 - SDK Manager] [SDK Manager] operable program or batch file.
Now I tried to update the Path variable in the computer settings so it looks like:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Users\bout0_000\android-sdks\platform-tools;C:\Program Files\Java\jdk1.7.0_11\bin
I just installed now again the JDK
And still when clicking on the icon of the Android SDK Manager though the Eclipse im getting this error.
This is the content of the find_java.bat file:
#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 This script is called by the other batch files to find a suitable `Java.exe`
rem to use. The script changes the "`java_exe`" env variable. The variable
rem is left unset if Java.exe was not found.
rem Useful links:
rem Command-line reference:
rem http://technet.microsoft.com/en-us/library/bb490890.aspx
rem Check we have a valid Java.exe in the path. The return code will
rem be 0 if the command worked or 1 if the exec failed (program not found).
for /f %%a in ('%~dps0\find_java.exe -s') do set java_exe=%%a
if not defined java_exe goto :CheckFailed
:SearchJavaW
rem Check if we can find a javaw.exe at the same location than java.exe.
rem If that doesn't work, just fall back on the java.exe we just found.
for /f %%a in ('%~dps0\find_java.exe -s -w') do set javaw_exe=%%a
if not exist %javaw_exe% set javaw_exe=%java_exe%
goto :EOF
:CheckFailed
echo.
echo ERROR: No suitable Java found. In order to properly use the Android Developer
echo Tools, you need a suitable version of Java JDK installed on your system.
echo We recommend that you install the JDK version of JavaSE, available here:
echo http://www.oracle.com/technetwork/java/javase/downloads
echo.
echo You can find the complete Android SDK requirements here:
echo http://developer.android.com/sdk/requirements.html
echo.
goto :EOF
This find_java.bat file is located in:
C:\Users\my user name\android-sdks\tools\lib
What else should I do ? This problem I think was from the beginning when using the Eclipse.
Have you told Eclipse where the Android SDK is via:-
Eclipse -> Preferences.
Click the Android section on the left hand side, and set the SDK Location. It should read:-
C:\Users\my user name\android-sdks
Thanks,
Ryan

Android SDK Manager will not run

i'm on a Windows 7 Pro x64 with java jdk 7u7.
I try to install the Android SDK on my computer, but when i launch SDK Manager.exe, a dos-windows is opening and instantly closing. So i tried to launch tools/android.bat. But that didn't work, it say to me that :
"'C:\PROGRA~2\Android\ANDROI~1\tools\lib\\find_java.exe -s' isn't a external or internal command ...
ERROR No suitable java such ..."
What i have do for fix error :
Install Java 6u35
Install Java x32 and x64
Check my path
Launch in administrator
Install in C:\Dev the sdk
Install with android-sdk.zip or with android-sdk.exe
Add android directory in path
But anyone of this try was successful.
Someone can help me?
There appear to be several ways to launch the SDK Manager:
SDK Manager.exe in the root of the Android SDK.
SDK Manager.exe in sdk\tools\lib of the Android SDK.
Window -> Android SDK Manager menu in Eclipse
android.bat in sdk\tools of the Android SDK.
In my case, it looks like android.bat fails on the line:
for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
As far as what that line is doing... if I manually run: "[path_to_java]java" -jar lib\archquery.jar
It successfully returns: x86_64
But when the batch file runs that same command, I don't know why but it fails with the error message:
Unable to access jarfile lib\archquery.jar
So the variable swt_path gets set to an empty string. Everything breaks down from there.
The batch file sets the correct value for the variable java_exe. Others have commonly reported this as a problem, but those workarounds weren't relevant in my case.
People have recommended commenting out the problem line by adding REM to the beginning of it, and adding a line to manually set the swt_path variable, which is a valid workaround:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
BUT, the critical issue in my case is that it's choosing to load a jar file from either the lib\x86 or the lib\x86_64 folder here. At some point, things were getting confused between the BAT file error, a 32-bit JDK, and a 64-bit Android SDK.
SO, the workaround in my case was to:
Uninstall ALL versions of Java
Install the JDK
You can either use the 32-bit Android SDK and install the 32-bit JDK
Or use the 64-bit Android SDK and install the 64-bit JDK
But the "bitness" of the JDK should match the Android SDK. It appears that either of the 32-bit or the 64-bit will work on a 64-bit computer, AS LONG AS the JDK bitness matches the Android SDK bitness.
Edit "android.bat"
If using the 32-bit Android SDK/JDK, use lib\x86:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
If using the 64-bit Android SDK/JDK, use lib\x86_64:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86_64
After doing this, I can successfully run the SDK Manager by running android.bat, or from the Eclipse menu (but still not by running either of the SDK Manager.exe files directly).
I had this answer just this week and have determined what is causing it.
When Java updates it changes the path where the executable files are stored. This means that when the SDK manager goes to look up javaw.exe it cannot find it and instantly closes.
Therefore re-installing the Android SDK will NOT solve the problem.
Neither will re-installing JAVA.
The only way to solve this problem is to correctly point to the location where JAVA is stored.
Windows has a way of doing this called an Environmental Variable.
There is a variable called PATH which stores all the directories where Windows will look for executable files.
Thus you have to to modify that PATH variable to include a path to JAVA.
By default JDK 7 has the following path:
C:\Program Files\Java\jdk1.7.0_10\bin
To edit your Environmental Variables do the following.
From the Start Menu right click on Computer and select "Properties"
This will take you to the Control Panel System Menu
On the left column look for the option "Advanced System Settings"
This will open a System Properties window
One of the tabs is named Advanced
In that there is a button that says Environmental Variables
If you search your System Variables you will see one called "Path"
Edit that variable and add the path above to include the latest Java Path.
Once you are done the SDK Manager should immediately be able to open up and you can continue updating to the latest revision of the Android SDK.
Once the updates complete don't forget to make sure your IDE (ie Eclipse) is pointing to the correct location where the SDK is stored so that it reads the latest Android SDK files. To access this setting in Eclipse, go to Window -> Preferences -> Android
This will allow you to manually set the path where the SDK is stored.
The only thing that helped me was reinstalling java into a path that did not contain any spaces, so instead of C:/Program Files to C:/Java and change the Path variable to the new value.
Hope this helps.
I had the same issue and it's most likely caused by spaces in the path names. It's known that spaces in path names and batch files don't combine well together.
You can verify that by opening a command line prompt, changing the location to %SDK%\tools\lib and running find_java.bat. You will get an batch error like
'C:\PROGRA~2\Android\Android' is not recognized as an internal or external command,
operable program or batch file.
Just install the SDK into C:\Android\SDK and the NDK into C:\Android\NDK and it will work.
This is how I finally fix it
open tools/android.bat
set java_exe=
call lib\find_java.bat
if not defined java_exe goto :EOF
replace it with your java path
set java_exe="c:\PROGRA~1\Java\jdk1.7.0\bin\java.exe"
Note:
Do not use C:\Program Files\Something it throw an error because of the space
use the short name notation C:\PROGRA~1\Something
and it will work like charm
Same issue for me SDK Manager.exe just stopping with no error message or windows event.
I fixed this with a hybrid of the already provided answers (I'm running on Win 8.1). The problem appears to be that the java.exe targeted by find_java was out-of-step with the recently installed JDK version.
for me:
<sdk> was C:\Users\Simon\AppData\Local\Android\sdk
<jdk> was C:\PROGRA~1\Java\jdk1.7.0_80\bin
I added my JDK install path to the PATH environment variable e.g. ...;C:\PROGRA~1\Java\jdk1.7.0_80\bin;...
After opening a new command window and running find_java.bat in the <sdk>\tools\lib\ folder I noticed that the java_exe env variable was set was to C:\Windows\System32\java.exe which was not what I expected.
I deleted (well renamed) the java.exe in C:\Windows\System32
I ran find_java.bat again and now the java_exe env variable was set to java_exe=<jdk>\java.exe as expected.
Then in <sdk> I could run SDK Manager.exe successfully.
Changing the JAVA_HOME from existing pointing to a JDK path to a JRE path works for me.

android is not recognized as an internal or external command

So I'm having the same issue as this guy in this question
android' is not recognized as an internal or external command
But when I changed my PATH variable and added the path to android.bat my cmd still does gives
'android' is not recognized as an internal or external command,
operable program or batch file.
My PATH looks like this
D:\Program Files\Java\jdk1.7.0_04\bin;D:\BossGrand\Programing\Ant\apache-ant-1.8.4\bin;C:\Program Files\TortoiseSVN\bin;D:\Program Files\Android\tools
and I made sure android.bat is inside D:\Program Files\Android\tools
I know this because when I go to this directory I can use the android update project command just fine
Does anyone know why I still can't use the android command?
Use the command prompt with admin .It work for me : )
You might have installed Cygwin as part of the SDK. I had the same problem "android.bat is not recognized as an internal or external command". So, Uninstall the Cygwin and try again (you might not able to uninstall Cygwin, since a mysterious “permission denied” when deleting the Cygwin files by default). You need to own access to this mysterious Cygwin files by doing
Take ownership: takeown /r /d y /f cygwin (do this, wherever is your cygwin folder is)
This command takes ownership recursive of the folder, without asking anything and gives Full Access to Everyone recursively in the folder:
icacls cygwin /t /grant Everyone:F And finally, the command which deletes it all and removes Cygwin:
rmdir /s /q cygwin Good bye Cygwin!
Now try again. (This worked for me)
PS: You can always re-install cygwin again. So, nothing wrong giving it a try. Good Luck
you must enter the command with complete arguments
android update project -p .
be carefull you must enter a dot at the end of command.

Unable to access jarfile lib\archquery.jar

Problem:
Unable to open SDK Manager (Flashes only for a second)
No build path target in Eclipse
Paths:
Android SDK: C:\Program Files\Android\android-sdk
JDK used for android: C:\Program Files\Java\jdk1.7.0_04 (There are other JDKs also in dir Java)
Environment Variables:
ANDROID_SDK_HOME: C:\Program Files\Android\android-sdk
JAVA_HOME: C:\Program Files\Java\jdk1.7.0_04;C:\Program Files (x86)\Java\jre1.6.0;C:\Program Files\Java\jre7;
System Path: C:\Program Files\Java\jdk1.7.0_04\bin;C:\Program Files\Java\jdk1.7.0_01\bin;C:\Program Files (x86)\Java\jdk1.5.0\bin;C:\Program Files\Android\android-sdk\tools\
Errors:
SDK Manager on cmd
Failed to execute tools\android.bat.
The system cannot find the file specified
Android.bat on cmd
Unable to access jar file lib\archquery.jar
Invalid path
find_java on cmd
nothing returned
I had a similar issue - I had to edit the android.bat ( and traceview.bat when I needed it)
in android.bat look for
for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
replace with
set swt_path=lib\x86
YMMV, but in addition to editing android.bat, as described in the previous answer, I still couldn't get the SDK Manager to run on Windows 8 64-bit, until I first:
uninstalled ALL versions of Java
rebooted*
installed ONLY the X86 JDK (including the Public JRE option in the installer)
I had tried all of these things and more previously *WITHOUT rebooting, and this was the only way I ever got the SDK Manager to run. Hopefully this info saves you from some of the utter frustration and wasted time I experienced. What a pain in the ass just to get the tools running out of the box. Awful experience.
I would have replied as a comment to the previous answer, but apparently I don't have enough rep to do that: https://meta.stackexchange.com/questions/25725/how-do-you-comment-on-a-specific-answer
EDIT: More complete answer below. (I don't think rebooting had anything to do with it.)
There appear to be several ways to launch the SDK Manager:
SDK Manager.exe in the root of the Android SDK.
SDK Manager.exe in sdk\tools\lib of the Android SDK.
Window -> Android SDK Manager menu in Eclipse
android.bat in sdk\tools of the Android SDK.
In my case, it looks like android.bat fails on the line:
for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
As far as what that line is doing... if I manually run: "[path_to_java]java" -jar lib\archquery.jar
It successfully returns: x86_64
But when the batch file runs that same command, I don't know why but it fails with the error message:
Unable to access jarfile lib\archquery.jar
So the variable swt_path gets set to an empty string. Everything breaks down from there.
The batch file sets the correct value for the variable java_exe. Others have commonly reported this as a problem, but those workarounds weren't relevant in my case.
People have recommended commenting out the problem line by adding REM to the beginning of it, and adding a line to manually set the swt_path variable, which is a valid workaround:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
BUT, the critical issue in my case is that it's choosing to load a jar file from either the lib\x86 or the lib\x86_64 folder here. At some point, things were getting confused between the BAT file error, a 32-bit JDK, and a 64-bit Android SDK.
SO, the workaround in my case was to:
Uninstall ALL versions of Java
Install the JDK
You can either use the 32-bit Android SDK and install the 32-bit JDK
Or use the 64-bit Android SDK and install the 64-bit JDK
But the "bitness" of the JDK should match the Android SDK. It appears that either of the 32-bit or the 64-bit will work on a 64-bit computer, AS LONG AS the JDK bitness matches the Android SDK bitness.
Edit "android.bat"
If using the 32-bit Android SDK/JDK, use lib\x86:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86
If using the 64-bit Android SDK/JDK, use lib\x86_64:
REM for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path=lib\x86_64
After doing this, I can successfully run the SDK Manager by running android.bat, or from the Eclipse menu (but still not by running either of the SDK Manager.exe files directly).
On Windows 7, at least, a batch 'FOR' loop, when executing a command for the list, does not use the current working directory, but the root. In this case, the command is '%java_exe% -jar lib\archquery.jar'. However, it's effectively being run from the root, e.g. 'C:\'. You can see this for your self with this simple test from the command line:
for /f %a in ('CD') do echo %a
So the command to run archquery is looking for the jar relative to the root directory, not your ADT directory, and thus can't be found.
I had similar issue and this is how it is solved.
Open android.bat file from \android-sdk-windows\tools in an editor.
Find the line
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
and add rem in front of this line.
In the next line add set swt_path=lib\x86 (if you are using a 32-bit system) or set swt_path=lib\x86_64 (if you are using a 64-bit system).
Save the file. Close the cmd if you have one open. Navigate to android-sdk-windows\tools\ and run android. This should open SDK manager. But be sure to have JAVA_HOME defined in your environment variables and should point to JDK home.
This change to android.bat (below) fixed the problem for me. I can launch the SDK manager from Eclipse now too.
for /f "delims=" %%a in ('"%java_exe%" -jar %~dp0\lib\archquery.jar') do set swt_path=lib\%%a
See What does %~dp0 mean, and how does it work?
I fixed that by replacing:
for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
with
REM for /f "delims=" %%a in ('"%java_exe%" -jar lib\archquery.jar') do set swt_path=lib\%%a
set swt_path="lib\x86_64"
Note that i used " for the swt_path variable.
Hope that could help someone else.
Adding an environmental variable called "ANDROID_SWT" pointing to the directory that holds swt.jar got this to work for me. Seems like a better option then modifying the script.

Categories

Resources