• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android Automated script for installing SDK dependencies (GMS 2.2.3 Windows)

FrostyCat

Member
Automated script for installing SDK dependencies (GMS 2.2.3 Windows)

There has been an uptick in SDK-related questions following the removal of Android Support Repository in Android Studio's SDK manager UI. In response, I have written an automated solution that attempts to resolve this.

Main Script

Copy and paste the following in a file named gms223sdk.bat:
Code:
@echo off
SETLOCAL EnableDelayedExpansion

rem Title
echo FrostyCat's GMS 2 Android SDK Dependency Installer
echo Version 1 for GMS 2.2.3
echo =======================================
echo.

rem Detect JDK
echo Searching for JDK...
if "%JAVA_HOME%" == "" (
    echo Error: JDK not found.
    exit /b 1
)
if not "x%JAVA_HOME:jre=%" == "x%JAVA_HOME%" (
    echo Error: Java path seems to point to JRE.
    exit /b 1
)
echo %JAVA_HOME%
echo.

rem Search for SDK directory
echo Searching for SDK...

if "%1" == "" (
    if exist "C:\Android\tools\bin\sdkmanager.bat" (
        set sdkdir=C:\Android
    )
    if exist "%localappdata%\Android\tools\bin\sdkmanager.bat" (
        set sdkdir=%localappdata%
    )
    if exist "%appdata%\Android\tools\bin\sdkmanager.bat" (
        set sdkdir=%appdata%\Android
    )
) else (
    if exist "%1\tools\bin\sdkmanager.bat" (
        set sdkdir=%1
    )
)
if not defined sdkdir (
    echo Error: SDK not found. If you wish to specify a non-default directory, run this: gms223sdk.bat ^<mysdkdir^>
    exit /b 1
)
echo !sdkdir!
echo.

rem Install dependencies as of 2019-09-07
echo Installing dependencies for SDK at !sdkdir!:
pushd "!sdkdir!\tools\bin"
call sdkmanager.bat "build-tools;28.0.3" "extras;android;m2repository" "extras;google;google_play_services" "extras;google;instantapps" "extras;google;m2repository" "extras;google;market_apk_expansion" "extras;google;market_licensing" "extras;google;usb_driver" "ndk-bundle" "patcher;v4" "platform-tools" "platforms;android-28"
echo.

rem Licensing
echo Licensing dependencies...
call sdkmanager.bat --licenses

rem Done
echo =======================================
echo.
echo Dependencies installed. In GMS 2, please configure File ^> Preferences ^> Platform Settings ^> Android as follows:
echo.
echo - Android SDK location: !sdkdir!
echo - Android NDK location: !sdkdir!\ndk-bundle
echo - Java JDK location: %JAVA_HOME%
echo.
popd
pause
Then simply double-click it to install the required SDK dependencies.

Technical Details

This script installs the following dependencies (for runtime 2.2.3.345):
  • Build tools 28.0.3
  • Android support repository
  • Google Play Services
  • Google Play Instant Development SDK
  • Google Repository
  • Google Play APK Expansion Library
  • Google Play Licensing Library
  • Google USB Driver
  • NDK
  • SDK Patch Applier v4
  • Android SDK Platform Tools
  • API Level 28

Last Updated: 2019-09-08: Enforce SDK tool detection when specifying a custom SDK directory.
 
Last edited:
Top