android.bat traz a GUI do SDK Manager, por que o sdkmanager.bat é necessário?

0

Minha informação de plataforma:

  • SO: Windows 7 (x86)
  • Java: jre1.8.0_111
  • SDK: tools_r25.2.3-windows.zip

Eu não estou usando o Android Studio; em vez disso, eu só preciso do desenvolvimento do SDK para o Apache Cordova.

Minha pergunta: Quando eu executei sdkmanager.bat , a GUI não aparece. Em vez disso, recebo uma saída de ajuda que exibe as opções da linha de comando (--list, etc).

Enquanto pesquisava sobre o problema, li em algum lugar que deveria executar android.bat diretamente. Eu fiz, e a GUI do gerente do SDK apareceu!

Qual é o lance com sdkmanager.bat ? Por que eu precisaria executar esse vs executando android.bat diretamente, como estou fazendo agora?

EDITAR:

conteúdo do sdkmanager.bat:

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem  sdkmanager startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..

@rem Add default JVM options here. You can also use JAVA_OPTS and SDKMANAGER_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Dcom.android.sdklib.toolsdir=%~dp0\.."

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*
goto execute

:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\lib\sdklib-25.3.0-dev.jar;%APP_HOME%\lib\layoutlib-api-25.3.0-dev.jar;%APP_HOME%\lib\dvlib-25.3.0-dev.jar;%APP_HOME%\lib\repository-25.3.0-dev.jar;%APP_HOME%\lib\gson-2.2.4.jar;%APP_HOME%\lib\commons-compress-1.8.1.jar;%APP_HOME%\lib\httpclient-4.1.1.jar;%APP_HOME%\lib\httpmime-4.1.jar;%APP_HOME%\lib\common-25.3.0-dev.jar;%APP_HOME%\lib\kxml2-2.3.0.jar;%APP_HOME%\lib\annotations-25.3.0-dev.jar;%APP_HOME%\lib\annotations-12.0.jar;%APP_HOME%\lib\jimfs-1.1.jar;%APP_HOME%\lib\httpcore-4.1.jar;%APP_HOME%\lib\commons-logging-1.1.1.jar;%APP_HOME%\lib\commons-codec-1.4.jar;%APP_HOME%\lib\guava-18.0.jar

@rem Execute sdkmanager
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %SDKMANAGER_OPTS%  -classpath "%CLASSPATH%" com.android.sdklib.tool.SdkManagerCli %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable SDKMANAGER_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%SDKMANAGER_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega

conteúdo do 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 enableextensions

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 "delims=" %%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\common.jar         "%tmp_dir%\lib\"          > nul
    copy /B /D /Y lib\commons-codec*     "%tmp_dir%\lib\"          > nul
    copy /B /D /Y lib\commons-compress*  "%tmp_dir%\lib\"          > nul
    copy /B /D /Y lib\commons-logging*   "%tmp_dir%\lib\"          > nul
    copy /B /D /Y lib\dvlib.jar          "%tmp_dir%\lib\"          > nul
    copy /B /D /Y lib\gson*              "%tmp_dir%\lib\"          > nul
    copy /B /D /Y lib\guava*             "%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
    copy /B /D /Y lib\layoutlib-api.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\swtmenubar.jar     "%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
    
por Sabuncu 29.12.2016 / 23:22

1 resposta

1

Você pode não apenas usar a ferramenta GUI para instalar / atualizar / remover componentes do SDK, como também pode usar o ferramenta de linha de comando :

sdkmanager

The sdkmanager is a command line tool that allows you to view, install, update, and uninstall packages for the Android SDK. [...]

The sdkmanager tool is provided in the Android SDK Tools package (25.2.3 and higher) and is located in android_sdk/tools/bin/.

Também pode ser adequado para scripts.

    
por 30.12.2016 / 12:31

Tags