Setting up Android SDK environment on Windows

  1. Install the Android command line tools. Go to Android Developer and download the tools that match your operating system.

    ../../_images/android-command-line-tool.png

    Extract the downloaded ZIP file to the directory where you want to install the SDK.

    Move the contents of the cmdline-tools folder to the latest folder. The final structure should be:

    D:\AndroidSDK\cmdline-tools\latest
    
  2. Configure related environment.

    Install Java. (If you have previously installed and configured Java, you need to check if your JDK is compatible with the command line tools. If the version is compatible, you can skip the following steps about Java environment configuration)

    Visit the official website of Oracle JDK and choose the version suitable for Windows to download.

    Here, you can use JDK-21.

    Then run the downloaded installer and follow the prompts to complete the installation. Make sure to note the installation path for future reference.

    D:\Java\jdk-21
    
  3. Set environment variables.

    Open the environment variable settings:

    • Right-click on This PC or Computer and select Properties.

    • Click on Advanced system settings.

    • In the System Properties window, select Environment Variables.


    In the System variables section, click New to add the JAVA_HOME variable, setting its value to the JDK installation path (D:\Java\jdk-21). Also, add the ANDROID_HOME variable, setting its value to the AndroidSDK installation path (D:\AndroidSDK).

    Find the Path variable, click Edit, and then add %JAVA_HOME%\bin, %ANDROID_HOME%\tools, %ANDROID_HOME%\emulator, %ANDROID_HOME%\cmdline-tools\latest\bin, %ANDROID_HOME%\tools\bin, %ANDROID_HOME%\cmdline-tools\latest, and %ANDROID_HOME%\platform-tools.

  4. Verify installation

    Open the command prompt: press Win + R, type cmd, and then press Enter.

    In the command prompt window, type java -version and javac -version, then press Enter.

    java -version
    javac -version
    sdkmanager --version
    

    If version information is displayed, it indicates that the configuration was successful.

  5. Verify if sdkmanager was successfully installed.

    sdkmanager --update
    sdkmanager --list
    sdkmanager --licenses
    

    Here, you should see information displaying All SDK package licenses accepted.

    You can learn more from the common commands of sdkmanager.