Introduction to Android SdkManager

About the author: CSDN content partner and technical expert, built an APP with tens of millions of daily users from scratch.
Focus on sharing original series of articles in various fields, specializing in java backend, mobile development, business realization, artificial intelligence, etc. I hope everyone will support me.

Insert image description here

1. Introduction

We continue to summarize and study ** basic knowledge **, review the past and learn new things.

This article talks about SdkManager

2. Overview

sdkmanager is a command line tool that can be used to view, install, update, and uninstall Android SDK packages.
If you use Android Studio, you do not need to use this tool and can manage SDK packages from the IDE.

3. Installation and use

3.1 Installation

To install a version of the command line tools using the SDK Manager, follow these steps:

  1. Download the latest "command line tools only" package from the Android Studio download page and unzip it.
    Insert image description here
  2. Move the unzipped cmdline-tools directory to the Android SDK directory.
  3. In the unzipped cmdline-tools directory, create a subdirectory named latest.
  4. Move the original cmdline-tools directory contents (including the lib directory, bin directory, NOTICE.txt file, and source.properties file) to the newly created latest directory.
  5. (Optional) To install legacy command line tools, run the following command:
android sdk/cmdline-tools/latest/bin/sdkmanager --install "cmdline-tools;version"

将 version 替换为要安装的版本,例如 5.0

3.2 Use

You can use sdkmanager to list installed and available packages, install packages, and update packages.

  • List installed and available packages
    To list installed and available packages, use the following syntax:
sdkmanager --list [options] \
           [--channel=channel_id] // Channels: 0 (stable), 1 (beta), 2 (dev), or 3 (canary)

Use the channel option to include packages from a channel up to and including channel_id. For example, specify the Canary channel to list packages for all channels.

  • Install package
    To install a package, use the following syntax:
sdkmanager packages [options]

The packages argument is the SDK-style path listed by the --list command, enclosed in quotes. For example, "build-tools;33.0.1" or "platforms;android-33".

Multiple package paths can be passed (separated by spaces), but each path must be enclosed in its own set of quotes. For example, here's how to install the latest platform tools and SDK tools for API level 33:

sdkmanager "platform-tools" "platforms;android-33"

Alternatively, you can pass a text file specifying all packages:

sdkmanager --package_file=package_file [options]

The package_file parameter specifies the location of a text file in which each line represents an SDK-style path (without quotes) to a package to be installed.

To uninstall, add the --uninstall flag:

sdkmanager --uninstall packages [options]
sdkmanager --uninstall --package_file=package_file [options]

To install CMake or NDK, use the following syntax:

sdkmanager --install
           ["ndk;major.minor.build[suffix]" | "cmake;major.minor.micro.build"]
           [--channel=channel_id] // NDK channels: 0 (stable), 1 (beta), or 3 (canary)

For example, use the following command to install a specific NDK version (regardless of which channel it is currently on):

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
  • Update all installed packages
sdkmanager --update [options]
  • Accept License
    You must accept the necessary license for each package you install. When you install a package through Android Studio, you need to complete this step during the installation process.

If you don't have Android Studio installed, or it's for a CI server or other headless Linux device that doesn't have a GUI installed, run the following command from the command line:

sdkmanager --licenses

You will be prompted to accept any unaccepted licenses.

3.3 Options

The following table lists the available options for the commands listed in the previous section:

Options illustrate
–sdk_root=path Use the specified SDK path instead of the SDK that contains this tool.
–channel=channel_id Packages included in channels with channel_id (inclusive). Available channels are: 0 (Stable), 1 (Beta), 2 (Development), and 3 (Canary).
–include_obsolete Include obsolete packages when listing or updating packages. Applies to --list and --update only.
–no_https Force all connections to use HTTP instead of HTTPS.
–newer When using --list, only new or updateable packages are shown.
–verbose Verbose output mode. This mode prints error, warning, and informational messages.
–proxy={http socks}
–proxy_host={IP_address DNS_address}
–proxy_port=port_number The proxy port number to connect to.

Reference
Official paper

4. Recommended reading

Java column

SQL Column

Data Structures and Algorithms

Android learning column

ddd
Without permission, shall not be reproduced.

Guess you like

Origin blog.csdn.net/fumeidonga/article/details/134063565