How to update SDK in Android Studio in the background
You can go to tools -> android -> sdk manager and click on Launch stand alone sdk manager hyperlink. This will open sdk manager outside android studio, select the packages and download. You can continue to work on android studio this way.
The "Launch standalone SDK Manager" option seems to be gone in Android Studio 2.3.3 for Windows. However, there is sdkmanager.bat in \tools\bin
It is possible to do it all by code using the sdkmanager tool.
The sdkmanager is a command line tool that allows you to view, install, update, and uninstall packages for the Android SDK.
This is an example using the sdkmanager with the command line:
- First at all, the sdkmanager is located in android_sdk/tools/bin/.
- Go where the sdkmanager is located
- List installed and available packages using this command:
sdkmanager --list
The result willl be something similar to this
- In my case I want to Download a System Image with Release Name "P" with ABI x86 ( I saw this information from Android Studio)
- The next step is to search that system image in your list
- Finally install this package in this way:
./sdkmanager "system-images;android-P;google_apis;x86"
This will begin the process of downloading the package
- After finish you can check that the image is available to use
For more info: https://developer.android.com/studio/command-line/sdkmanager.html#usage