sdkmanager --install "ndk;21.3.6528147" --channel=3 // Install the NDK from the canary channel (or below)
sdkmanager --install "cmake;10.24988404" // Install a specific version of CMake
更新所有已安装的软件包
如需更新所有已安装的软件包,请使用以下语法:
sdkmanager --update [options]
接受许可
您必须为已安装的每个软件包接受必要的许可。当您通过 Android Studio 安装软件包时,就需要在安装过程中完成此步骤。
如果您未安装 Android Studio,或者它适用于 CI 服务器或其他未安装 GUI 的无头 Linux 设备,请在命令行中运行以下命令:
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# sdkmanager\n\nThe `sdkmanager` is a command-line tool that lets you view, install,\nupdate, and uninstall packages for the Android SDK. If you're using Android\nStudio, then you don't need to use this tool, and you can instead [manage your\nSDK packages from the IDE](/studio/intro/update#sdk-manager).\n\nThe `sdkmanager` tool is provided in the\n[Android SDK Command-Line Tools](/studio/command-line#tools-sdk) package.\nTo use the SDK Manager to install a version of the command-line tools,\nfollow these steps:\n\n1. Download the latest [command line tools package](/studio#command-line-tools-only) from the [Android Studio](/studio) page and extract the package.\n2. Move the unzipped `cmdline-tools` directory into a new directory of your choice, such as \u003cvar translate=\"no\"\u003eandroid_sdk\u003c/var\u003e. This new directory is your Android SDK directory.\n3. In the unzipped `cmdline-tools` directory, create a sub-directory called `latest`.\n4. Move the original `cmdline-tools` directory contents, including the `lib` directory, `bin` directory, `NOTICE.txt` file, and `source.properties` file, into the newly created `latest` directory. You can now use the command-line tools from this location.\n5. (Optional) To install a previous version of the command-line tools, run\n the following command:\n\n ```\n android_sdk/cmdline-tools/latest/bin/sdkmanager --install \"cmdline-tools;version\"\n ```\n Substitute \u003cvar translate=\"no\"\u003eversion\u003c/var\u003e with the version you want to install, for example `5.0`. **Note:** For local usage, you can use the `latest` packages. For scripts, choose a specific version instead to ensure stability.\n\nUsage\n-----\n\nYou can use the `sdkmanager` to list installed and available packages, install\npackages, and update packages. For more details, see the following sections.\n\n### List installed and available packages\n\nTo list installed and available packages, use the following syntax: \n\n```\nsdkmanager --list [options] \\\n [--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary)\n```\n\nUse the `channel` option to include a package from a channel up to and\nincluding `channel_id`. For example, specify the canary channel to list\npackages from all channels.\n| **Note:** To list only stable packages, use `--channel=0` or remove the `--channel` option entirely.\n\n### Install packages\n\nTo install packages, use the following syntax: \n\n```\nsdkmanager packages [options]\n```\n\nThe \u003cvar translate=\"no\"\u003epackages\u003c/var\u003e argument is an SDK-style path, as shown with\nthe `--list` command, wrapped in quotes. For example,\n`\"build-tools;35.0.0\"` or\n`\"platforms;android-33\"`.\n\nYou can pass multiple package\npaths, separated with a space, but they must each be wrapped in their own set of\nquotes. For example, here's how to install the latest platform tools and\nthe SDK tools for API level 33: \n\n sdkmanager \"platform-tools\" \"platforms;android-33\"\n\nAlternatively, you can pass a text file that specifies all packages: \n\n```\nsdkmanager --package_file=package_file [options]\n```\n\nThe \u003cvar translate=\"no\"\u003epackage_file\u003c/var\u003e argument is the location of a text file in which\neach line is an SDK-style path of a package to install (without quotes).\n\nTo uninstall, add the `--uninstall` flag: \n\n```\nsdkmanager --uninstall packages [options]\nsdkmanager --uninstall --package_file=package_file [options]\n```\n\nTo install CMake or the NDK, use the following syntax: \n\n```transact-sql\nsdkmanager --install\n [\"ndk;\u003cvar translate=\"no\"\u003emajor\u003c/var\u003e.\u003cvar translate=\"no\"\u003eminor\u003c/var\u003e.\u003cvar translate=\"no\"\u003ebuild\u003c/var\u003e[\u003cvar translate=\"no\"\u003esuffix\u003c/var\u003e]\" | \"cmake;major.minor.micro.build\"]\n [--channel=\u003cvar translate=\"no\"\u003echannel_id\u003c/var\u003e] // NDK channels: 0 (stable), 1 (beta), or 3 (canary)\n```\n\nFor example, use the following command to install the specified NDK version\nregardless of which channel it is currently on: \n\n```text\nsdkmanager --install \"ndk;21.3.6528147\" --channel=3 // Install the NDK from the canary channel (or below)\nsdkmanager --install \"cmake;10.24988404\" // Install a specific version of CMake\n```\n\n### Update all installed packages\n\nTo update all installed packages, use the following syntax: \n\n```\nsdkmanager --update [options]\n```\n\n### Accept licenses\n\nYou are required to accept the necessary license for each package you have\ninstalled. This step occurs during the installation flow when you install\npackages from within Android Studio.\n\nIf you don't have Android Studio installed, or it is for a CI server\nor other headless Linux device without a GUI installed, do the\nfollowing from the command-line: \n\n```text\nsdkmanager --licenses\n```\n\nThis prompts you to accept any licenses that haven't already been accepted.\n\nOptions\n-------\n\nThe following table lists the available options for the commands listed in the preceding section:\n\n| Option | Description |\n|-----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| `--sdk_root=`**\u003cvar translate=\"no\"\u003epath\u003c/var\u003e** | Use the specified SDK path instead of the SDK containing this tool. |\n| `--channel=`**\u003cvar translate=\"no\"\u003echannel_id\u003c/var\u003e** | Include packages in channels up to and including channel_id. Available channels are: `0` (Stable), `1` (Beta), `2` (Dev), and `3` (Canary). |\n| `--include_obsolete` | Include obsolete packages in the package listing or package updates. For use with `--list` and `--update` only. |\n| `--no_https` | Force all connections to use HTTP rather than HTTPS. |\n| `--newer` | With `--list`, show only new or updatable packages. |\n| `--verbose` | Verbose output mode. Errors, warnings and informational messages are printed. |\n| `--proxy={http | socks}` | Connect via a proxy of the given type: either `http` for high level protocols such as HTTP or FTP, or `socks` for a SOCKS (V4 or V5) proxy. |\n| `--proxy_host={`**\u003cvar translate=\"no\"\u003eIP_address\u003c/var\u003e**` | `**\u003cvar translate=\"no\"\u003eDNS_address\u003c/var\u003e**`}` | IP or DNS address of the proxy to use. |\n| `--proxy_port=`**\u003cvar translate=\"no\"\u003eport_number\u003c/var\u003e** | Proxy port number to connect to. |\n\n| **Note:** If you want to install packages for an operating system different from the current machine, set the [`REPO_OS_OVERRIDE`](/studio/command-line/variables#repo_os_override) environment variable to either `\"windows\"`, `\"macosx\"`, or `\"linux\"`."]]