40

I want to list the installed sdk packages by command lines.(For some reasons I cannot use the GUI)

I have done some research and found out several commands to list the available packages on the remote server, but I fail to find any command to list the installed sdk packages yet.

Thanks

hackjutsu
  • 8,336
  • 13
  • 47
  • 87

8 Answers8

34

With Android SDK Tools 25.2.3 (and higher):

$ANDROID_HOME/tools/bin/sdkmanager --list

See: https://developer.android.com/studio/command-line/sdkmanager.html#usage

tnissi
  • 907
  • 1
  • 8
  • 12
  • 15
    This lists all packages, installed or not. `In its third form, all installed and available packages are printed out.` Is there a variant that only returns the installed packages, and returns them in a useful format to reinstall the same package set somewhere else? – David Berry Feb 17 '17 at 20:54
  • 3
    There's no such variant as far as I know. Installed packages have their own table and the first column lists the package path, that you'll need when installing. So the info is there and just some shell magic is needed to extract it. – tnissi Feb 20 '17 at 13:39
  • Alternative commands [from here](https://stackoverflow.com/a/44229861/1009132) `sdkmanager --list --verbose` since version 26.0.1 and `find ~/.android-sdk/ -name package.xml -exec sh -c 'eval $(xmllint --xpath "//*[local-name()='\'localPackage\'']/@path" $0) && echo $path' {} \;` to list only installed packages – albodelu May 28 '17 at 19:09
  • 13
    @DavidBerry `sdkmanager --list | sed -e '/Available Packages/q'` will quickly just print the installed packages (a "little" bit shorter than @albodelu variant). – Dominik Jul 26 '17 at 13:52
13

If you have your path set up, run

sdkmanager --list_installed

This will print out all the packages installed using sdkmanager.

4

For those want to use awk getting the inner paragraph between "Installed packages" and "Aavaliable Packages", but not include "Installed packages" and "Aavaliable Packages" lines.

sdkmanager  --list | awk '/Installed/{flag=1; next} /Available/{flag=0} flag'
timtor chen
  • 133
  • 11
3

As described in $ANDROID_HOME/tools/android list --help

  • list : Lists existing targets or virtual devices.
  • list avd : Lists existing Android Virtual Devices.
  • list target : Lists existing targets.
  • list device : Lists existing devices.
  • list sdk : Lists remote SDK repository.

I guess you are looking for this:

$ANDROID_HOME/tools/android list target

You can learn more on the android tool in the Command Line Reference.

Good luck!

gabocalero
  • 473
  • 6
  • 15
  • Cool, can you share the reference links? – hackjutsu Dec 29 '15 at 19:28
  • 4
    This answer did not answer the posters question. I have the same problem. To build my Android project, I want to automatically install the Android SDK and any modules it needs. I don't know how to tell if a module is already installed. – Chuck Doucette Jun 03 '16 at 18:18
  • In my limited investigation, it appears that: a) you can tell if a certain version of build-tools is installed by looking in the build-tools subdirectory where you installed the Android SDK (e.g. /usr/local/android-sdk-macosx/build-tools), b) perhaps other modules are stored in the add-ons subdirectory, c) target platforms appear to be installed in platforms. – Chuck Doucette Jun 03 '16 at 19:40
  • 12
    As noted, this doesn't answer the question of how to list packages that are already installed. – David Berry Jul 08 '16 at 17:04
  • 1
    This is listing AVD targets, nothing to do with the Q – Dori Nov 01 '16 at 13:36
2

On my mac just sdkmanager --list was not working, path needed to be specified.

Using android studio default SDK location the path is ~/Library/Android/sdk/tools/bin/sdkmanager --list

As mentioned by @tnissi this is for Android SDK Tools 25.2.3 (and higher).

Or add the path by: export PATH=$PATH:~/Library/Android/sdk/tools/bin

Rick
  • 1,177
  • 1
  • 19
  • 27
2

in case you need only the installed packages with full names

sdkmanager --verbose --list | sed -n '/^Installed packages:$/,/^Available Packages:$/p'
emrhzc
  • 1,347
  • 11
  • 19
0

It's not quite a listing, but the source.properties files give details of the provenance. I'm using this to compare SDKs on different machines:

for i in $(find -name source.properties); do
  if [ -e ../other.sdk/$i ] ; then
    echo ========================= $i
    diff -wu $i ../other.sdk/$i | grep -v Pkg.License
  fi
done

I strip Pkg.License because it's hyoooj.

android.weasel
  • 3,343
  • 1
  • 30
  • 41
0

A bit old topic but I had similar problem, And noticed that avdmanager lists installed platforms as targets

"%ANDROID_SDK_ROOT%\tools\bin\avdmanager" list target

Available Android targets:==============] 100% Fetch remote repository...
----------
id: 1 or "android-25"
     Name: Android API 25
     Type: Platform
     API level: 25
     Revision: 3
----------
id: 2 or "android-28"
     Name: Android API 28
     Type: Platform
     API level: 28
     Revision: 6