Win10论坛

Win10正式版系统下载主题平板

重定义Modern UI,打造完美Windows全新体验

Windows10下载|安装|新手宝典|必备软件

搜索
查看: 6381|回复: 4

[分享] WIN8下的Android SDK 秒退的解决方法 [复制链接]

Rank: 2Rank: 2

UID
1921953
帖子
133
PB币
1453
贡献
0
技术
22
活跃
23
发表于 2012-11-28 23:56:57 |显示全部楼层
网上有人说,这是Android SDK的bug。然后,也有人说,JDK的安装路径不允许存在空格,例如C:\Program Files\jdk-1.6.0-31。
但是后来用以下方法,验证可用。找到Android SDK的安装目录下 android-sdk-windows/tools/lib/find_java.bat批处理文件,备份一下。(随便重命名,更改后缀格式)。
然后新建同名格式文件,将以下内容粘贴复制,保存即可。
然后,启动 SDK Manager ,可以打开窗口。
  1. @echo off
  2. rem Copyright (C) 2007 The Android Open Source Project
  3. rem
  4. rem Licensed under the Apache License, Version 2.0 (the "License");
  5. rem you may not use this file except in compliance with the License.
  6. rem You may obtain a copy of the License at
  7. rem
  8. rem      http://www.apache.org/licenses/LICENSE-2.0
  9. rem
  10. rem Unless required by applicable law or agreed to in writing, software
  11. rem distributed under the License is distributed on an "AS IS" BASIS,
  12. rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. rem See the License for the specific language governing permissions and
  14. rem limitations under the License.

  15. rem This script is called by the other batch files to find a suitable Java.exe
  16. rem to use. The script changes the "java_exe" env variable. The variable
  17. rem is left unset if Java.exe was not found.

  18. rem Useful links:
  19. rem Command-line reference:
  20. rem   http://technet.microsoft.com/en-us/library/bb490890.aspx

  21. rem Check we have a valid Java.exe in the path. The return code will
  22. rem be 0 if the command worked or 9009 if the exec failed (program not found).
  23. rem Java itself will return 1 if the argument is not understood.
  24. set java_exe=java.exe
  25. rem search it in the path and verify we can execute it
  26. for %%a in (%java_exe%) do set java_exe=%%~s$PATH:a
  27. if not exist %java_exe% goto SearchForJava
  28. %java_exe% -version 2>nul
  29. if ERRORLEVEL 1 goto SearchForJava
  30. goto :SearchJavaW


  31. rem ---------------
  32. :SearchForJava
  33. rem We get here if the default %java_exe% was not found in the path.
  34. rem Search for an alternative in %ProgramFiles%\Java\*\bin\java.exe

  35. echo.
  36. echo WARNING: Java not found in your path.

  37. rem The strategy is to look for Java under these 3 locations:
  38. rem - %ProgramFiles%, which may point to either a 32-bit or 64-bit install
  39. rem                   depending on the current invocation context
  40. rem - %ProgramW6432%, which points to a 32-bit install. This may not be defined.
  41. rem - %ProgramFiles(x86)%, which points to a 64-bit install. This may not be defined.

  42. if not defined ProgramFiles goto :Check64
  43. echo Checking if Java is installed in %ProgramFiles%\Java.

  44. set java_exe=
  45. for /D %%a in ( "%ProgramW6432%\Java\*" ) do call :TestJavaDir "%%a"
  46. if defined java_exe goto :SearchJavaW

  47. rem Check for the "default" 64-bit version if it's not the same path
  48. :Check64
  49. if not defined ProgramW6432 goto :Check32
  50. if "%ProgramW6432%"=="%ProgramFiles%" goto :Check32
  51. echo Checking if Java is installed in %ProgramW6432%\Java instead (64-bit).

  52. set java_exe=
  53. for /D %%a in ( "%ProgramW6432%\Java\*" ) do call :TestJavaDir "%%a"
  54. if defined java_exe goto :SearchJavaW

  55. rem Check for the "default" 32-bit version if it's not the same path
  56. :Check32
  57. if not defined ProgramFiles(x86) goto :CheckFailed
  58. if "%ProgramFiles(x86)%"=="%ProgramFiles%" goto :CheckFailed
  59. echo Checking if Java is installed in %ProgramFiles(x86)%\Java instead (32-bit).

  60. set java_exe=
  61. for /D %%a in ( "%ProgramFiles(x86)%\Java\*" ) do call :TestJavaDir "%%a"
  62. if defined java_exe goto :SearchJavaW

  63. :CheckFailed
  64. echo.
  65. echo ERROR: No suitable Java found. In order to properly use the Android Developer
  66. echo Tools, you need a suitable version of Java JDK installed on your system.
  67. echo We recommend that you install the JDK version of JavaSE, available here:
  68. echo   http://www.oracle.com/technetwork/java/javase/downloads
  69. echo.
  70. echo You can find the complete Android SDK requirements here:
  71. echo   http://developer.android.com/sdk/requirements.html
  72. echo.
  73. goto :EOF

  74. rem ---------------
  75. :TestJavaDir
  76. rem This is a "subrountine" for the for /D above. It tests the short version
  77. rem of the %1 path (i.e. the path with only short names and no spaces).
  78. rem However we use the full version without quotes (e.g. %~1) for pretty print.
  79. if defined java_exe goto :EOF
  80. set full_path=%~1\bin\java.exe
  81. set short_path=%~s1\bin\java.exe

  82. %short_path% -version 2>nul
  83. if ERRORLEVEL 1 goto :EOF
  84. set java_exe=%short_path%

  85. echo.
  86. echo Java was found at %full_path%.
  87. echo Please consider adding it to your path:
  88. echo - Under Windows XP, open Control Panel / System / Advanced / Environment Variables
  89. echo - Under Windows Vista or Windows 7, open Control Panel / System / Advanced System Settings / Environment Variables
  90. echo At the end of the "Path" entry in "User variables", add the following:
  91. echo   ;%full_path%
  92. echo.
  93. goto :EOF

  94. rem ---------------
  95. :SearchJavaW
  96. rem Called once java_exe has been set. Try to see if we can find a javaw
  97. rem to use. If not, we'll default to using java_exe.
  98. for %%a in (%java_exe%) do set p=%%~pa
  99. for %%a in (%java_exe%) do set n=%%~na
  100. for %%a in (%java_exe%) do set x=%%~xa
  101. set n=%n:java=javaw%
  102. set javaw_exe=%p%%n%%x%
  103. if not exist %javaw_exe% set javaw_exe=%java_exe%
  104. goto :EOF
复制代码

Rank: 2Rank: 2

UID
693390
帖子
176
PB币
495
贡献
0
技术
3
活跃
40
发表于 2012-12-3 12:34:12 |显示全部楼层
支持,谢谢分享!!!

Rank: 5Rank: 5Rank: 5

UID
987864
帖子
489
PB币
1108
贡献
0
技术
1
活跃
437
发表于 2012-12-26 04:15:11 |显示全部楼层
今天装过,啥都不用改就行拉阿

Rank: 2Rank: 2

UID
2835616
帖子
210
PB币
801
贡献
0
技术
0
活跃
161
发表于 2013-8-14 22:57:28 |显示全部楼层
直接找到tools下的android.bat,然后打开即可。。。

Rank: 5Rank: 5Rank: 5

UID
974201
帖子
441
PB币
1014
贡献
0
技术
5
活跃
25
发表于 2013-9-9 09:32:50 |显示全部楼层
mark一下。果然管用,该死的google
关闭

站长推荐

推荐好友加入远景可拿奖励
推荐好友进远景,可以拿3重奖励,PBB,威望,勋章,通通有~ 本帖只限回复推荐用
回顶部
Copyright (C) 2005-2019 pcbeta.com, All rights reserved
Powered by Discuz!  苏ICP备17027154号
请勿发布违反中华人民共和国法律法规的言论,会员观点不代表远景论坛官方立场。
远景在线 | 远景论坛 | 苹果论坛 | Win10论坛 | Win8论坛 | Win7论坛 | WP论坛 | Office论坛 | 电脑硬件 | 安卓软件