I'm having a problem getting my android dev environment setup in Windows 7. I follow the instructions here, as well as several environment sublinks. I am using Eclipse with the Android plugin. I have installed the Java JDK several times, in various locations (jdk-6u20-windows-i586.exe) - but I am obviously missing something.
Every time I run "android create avd --target 2 --name my_avd" I get an error:
C:\Users\andrew>android create avd --target 2 --name my_avd
WARNING: Java not found in your path.
Checking it it's installed in C:\Program Files\Java instead.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java installed on your system. We
recommend that you install the JDK version of JavaSE, available here:
http://java.sun.com/javase/downloads/
You can find the complete Android SDK requirements here:
http://developer.android.com/sdk/requirements.html
This error message is the reason for me installing the JDK several times over. First I tried installing to a location on my e: drive. I then moved it to the default loc (program files (x86)\\java\\jdk.6.something. I also tried forcing it to go into the program files\\ path, but it still automatically installs into the (x86) path. I have added the install path to my path environment variable every single time, yet I still continue to get this error. My suspicion is that windows 7 and the android tools are not playing together well in terms of finding the JDK, but who knows, it may be something entirely different. If you have seen this error before, I would appreciate a hint.
I had this same problem, after accidentally installed the 32-bit version of Java SDK. I uninstalled it and installed the 64-bit version (since I'm using Windows 7 64). The Android SDK setup never found Java correctly, even after I added it to my PATH variable!
After a bit of digging around, I discovered a java.exe floating around in my system32 folder, which in the order of the PATH variable came before my SDK path. After whacking the java.exe in my system32 folder, the Android Setup ran just fine!
Hope this helps.
The android
command is just a Windows Batch file which in turn uses the batch file tools\\lib\\find_java.bat
to find Java.
Having a look at the source, it does the following:
java.exe
is on your PATH
. java.exe
in somewhere under %ProgramFiles%
Your problem arises because you're using the a 64-bit version of Windows. This means %ProgramFiles%
is C:\\Program Files
but Java is installed in C:\\Program Files (x86)
as it's a 32-bit application, meaning find_java.bat
doesn't find it.
So to fix this you'll need to add the directory containing java.exe
to your PATH environment variable.
You'll need to the add the directory containing java.exe
- something like C:\\Program Files (x86)\\Java\\jdk6\\bin
- on to the end of PATH
with a semicolon in front of it to separate it from the previous entry.
This question on superuser.com covers maintaining Environment Variables in Windows 7.
It is really hell with JDK detection...
My params: Win 7 x64 + JDK x64 (JDK path (c:\\Program Files\\Java\\jre7\\bin)
Was googling and playing around with env variables may be 1 hour - no way.
Finally come with such solution
Manually edit android-sdk-windows\\tools\\lib\\find_java.bat
by hardcoding the path to java.exe
set java_exe=c:\Progra~1\Java\jre7\bin\java.exe
if not defined java_exe goto :CheckFailed
:SearchJavaW
set javaw_exe=c:\Progra~1\Java\jre7\bin\javaw.exe
if not exist %javaw_exe% set javaw_exe=%java_exe%
goto :EOF
Thats works for me.
In the SDK tools folder go to libs and edit find_java.bat
. It can usually be found in C:\\Program Files (x86)\\Android\\android-sdk-windows\\tools\\lib
.
Change all instances of %PROGRAMFILES%
to %PROGRAMFILES(X86)%
.
I did this and the error went away.
I put rem statement in android.bat after the call command and hardcode the path of \\bin\\java.exe:
rem Check we have a valid Java.exe in the path.
set java_exe=<..>\jdk1.6.0_31\bin\java.exe
rem call lib\find_java.bat
if not defined java_exe goto :EOF
Same for setting other variable javaw_exe thus:
set javaw_exe=<..>\jre1.6.0_31\bin\javaw.exe
if not exist %javaw_exe% set javaw_exe=%java_exe%
goto :EOF
Find android-sdk-windows\\tools\\lib\\find_java.bat
and add something like the following:
set java_exe=
call :TestJavaDir "%JAVA_HOME%"
if defined java_exe goto :EOF
What worked for me was this:
add a path to your java/bin directory to the system Path variable. Do NOT include java.exe.
Steps on Win 7 64bit:
Try it out!
hth,
\\ ^ / ill
C:\\Windows\\SysWOW64
1down vote
I also had this same problem -> accidentally installed the 32-bit version of Java SDK -> uninstalled -> installed the 64-bit version (Windows 7 64) -> -> the Android SDK setup never found Java correctly!
I discovered a java.exe floating around in C:\\Windows\\SysWOW64 folder. After renaming this java.exe to javaX.exe, the Android Setup ran just fine!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.