当前位置: 代码迷 >> Android >> 解决win8下AndroidSDK秒退的有关问题
  详细解决方案

解决win8下AndroidSDK秒退的有关问题

热度:9   发布时间:2016-05-01 10:24:29.0
解决win8下AndroidSDK秒退的问题

找到安装目录下android-sdk-windows/tools/lib/find_java.bat批处理文件,将其内容替换为,如下所示

@echo offrem Copyright (C) 2007 The Android Open Source Projectremrem 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 atremrem      http://www.apache.org/licenses/LICENSE-2.0remrem Unless required by applicable law or agreed to in writing, softwarerem 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 andrem limitations under the License. rem This script is called by the other batch files to find a suitable Java.exerem to use. The script changes the "java_exe" env variable. The variablerem 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 willrem be 0 if the command worked or 9009 if the exec failed (program not found).rem Java itself will return 1 if the argument is not understood.set java_exe=java.exerem search it in the path and verify we can execute itfor %%a in (%java_exe%) do set java_exe=%%~s$PATH:aif not exist %java_exe% goto SearchForJava%java_exe% -version 2>nulif ERRORLEVEL 1 goto SearchForJavagoto :SearchJavaW  rem ---------------:SearchForJavarem We get here if the default %java_exe% was not found in the path.rem Search for an alternative in %ProgramFiles%\Java\*\bin\java.exe echo.echo WARNING: Java not found in your path. rem The strategy is to look for Java under these 3 locations:rem - %ProgramFiles%, which may point to either a 32-bit or 64-bit installrem                   depending on the current invocation contextrem - %ProgramW6432%, which points to a 32-bit install. This may not be defined.rem - %ProgramFiles(x86)%, which points to a 64-bit install. This may not be defined. if not defined ProgramFiles goto :Check64echo Checking if Java is installed in %ProgramFiles%\Java. set java_exe=for /D %%a in ( "%ProgramW6432%\Java\*" ) do call :TestJavaDir "%%a"if defined java_exe goto :SearchJavaW rem Check for the "default" 64-bit version if it's not the same path:Check64if not defined ProgramW6432 goto :Check32if "%ProgramW6432%"=="%ProgramFiles%" goto :Check32echo Checking if Java is installed in %ProgramW6432%\Java instead (64-bit). set java_exe=for /D %%a in ( "%ProgramW6432%\Java\*" ) do call :TestJavaDir "%%a"if defined java_exe goto :SearchJavaW rem Check for the "default" 32-bit version if it's not the same path:Check32if not defined ProgramFiles(x86) goto :CheckFailedif "%ProgramFiles(x86)%"=="%ProgramFiles%" goto :CheckFailedecho Checking if Java is installed in %ProgramFiles(x86)%\Java instead (32-bit). set java_exe=for /D %%a in ( "%ProgramFiles(x86)%\Java\*" ) do call :TestJavaDir "%%a"if defined java_exe goto :SearchJavaW :CheckFailedecho.echo ERROR: No suitable Java found. In order to properly use the Android Developerecho 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/downloadsecho.echo You can find the complete Android SDK requirements here:echo   http://developer.android.com/sdk/requirements.htmlecho.goto :EOF rem ---------------:TestJavaDirrem This is a "subrountine" for the for /D above. It tests the short versionrem of the %1 path (i.e. the path with only short names and no spaces).rem However we use the full version without quotes (e.g. %~1) for pretty print.if defined java_exe goto :EOFset full_path=%~1\bin\java.exeset short_path=%~s1\bin\java.exe %short_path% -version 2>nulif ERRORLEVEL 1 goto :EOFset java_exe=%short_path% echo.echo Java was found at %full_path%.echo Please consider adding it to your path:echo - Under Windows XP, open Control Panel / System / Advanced / Environment Variablesecho - Under Windows Vista or Windows 7, open Control Panel / System / Advanced System Settings / Environment Variablesecho At the end of the "Path" entry in "User variables", add the following:echo   ;%full_path%echo.goto :EOF rem ---------------:SearchJavaWrem Called once java_exe has been set. Try to see if we can find a javawrem to use. If not, we'll default to using java_exe.for %%a in (%java_exe%) do set p=%%~pafor %%a in (%java_exe%) do set n=%%~nafor %%a in (%java_exe%) do set x=%%~xaset n=%n:java=javaw%set javaw_exe=%p%%n%%x%if not exist %javaw_exe% set javaw_exe=%java_exe%goto :EOF

?注意需要设置jdk环境变量,否则做上面的修改后还是秒退。

  相关解决方案