11

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.

lopsided98
  • 559
  • 1
  • 9
  • 18
  • Just in case: do you use JDK 6? I read somewhere that it will not run on JDK 7, it should be JDK 6 for the Android SDK to run. – Vit Khudenko Jun 13 '12 at 21:02
  • @Arhimed I tried this solution (you're right, it says on the Android SDK website to use JDK6), but sadly it didn't seem to change anything. – lopsided98 Jun 13 '12 at 23:56
  • Related: https://stackoverflow.com/questions/33367823/vs-android-not-suitable-java-found – Chanandler Bong Jan 24 '20 at 15:37

13 Answers13

8

This is how I got it to work on Windows 8

  1. 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)

  2. 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

  3. 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

deko
  • 2,534
  • 3
  • 34
  • 48
user2345534
  • 81
  • 1
  • 1
5

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

merlin
  • 66
  • 1
  • 2
3

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.

Community
  • 1
  • 1
Julian Higginson
  • 547
  • 4
  • 12
  • I tried replacing the backslashes with forward slashes but it didn't seem to do anything either. – lopsided98 Jun 14 '12 at 11:02
  • damn... is it possible all the hacking you did broke something else? my win764 install is happy with the ADK, so it can work somehow... glad you got something working. how well does the ADB work from a VM to an android device? (or are you just using the emulator?) – Julian Higginson Jul 05 '12 at 12:12
  • I reinstalled the ADK and then tried changing the backslashes to forward slashes and it still didn't work. :( – lopsided98 Jul 05 '12 at 17:15
  • have you tried just using 32 bit Java? I know that it's kinda admitting defeat, but as I understand it, this will work on Win7, and probably less hassle than going all the way to a 32bit VM running 32 bit java. (I just chose to fight the non working toolchain using 64 bit java install because I was excited about finally having a 64 bit system and didn't want to give up on using full 64 bit software where it's possible) – Julian Higginson Jul 09 '12 at 00:36
2

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.

Todd
  • 21
  • 2
1

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

1

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.

Dhanuka
  • 2,826
  • 5
  • 27
  • 38
Tomym617
  • 11
  • 1
0

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.

Prakash
  • 11
  • 2
0

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.

Joseph Lennox
  • 3,202
  • 1
  • 27
  • 25
0

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.

Rajesh
  • 654
  • 5
  • 8
0

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

Jaydeep
  • 41
  • 3
0

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
MZB
  • 2,071
  • 3
  • 21
  • 38
0

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.

deko
  • 2,534
  • 3
  • 34
  • 48
0

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

MAbdulHalim
  • 389
  • 4
  • 14