简体   繁体   English

如何在不下载 Android Studio 的情况下下载 Android SDK?

[英]How do I download the Android SDK without downloading Android Studio?

As of the moment, I am running a Windows 8.1 PC that does not have the storage or the RAM for a IDE like Android Studio or Eclipse. As of the moment, I am running a Windows 8.1 PC that does not have the storage or the RAM for a IDE like Android Studio or Eclipse. I want to download the Android SDK tools, without the IDE.我想下载 Android SDK 工具,没有 IDE。 How can this be accomplished?如何实现?

You can find the command line tools at the downloads page under the "Command line tools only" section.您可以在 下载页面的“仅限命令行工具”部分下找到命令行工具。

在此处输入图片说明

These are the links provided in the page as of now (version 26.1.1):这些是截至目前页面中提供的链接(版本 26.1.1):

Be sure to have read and agreed with the terms of service before downloading any of the command line tools.在下载任何命令行工具之前,请务必阅读并同意服务条款。

The installer version for windows doesn't seem to be available any longer, this is the link for version 24.4.1: Windows 的安装程序版本似乎不再可用,这是 24.4.1 版的链接:

Navigate to the "Get just the command line tools" section of the android downloads page, and download the tools for your system.导航到 android下载页面的“仅获取命令行工具”部分,然后下载适用于您系统的工具。

For Windows:对于 Windows:

Extract the contents to C:\\Android\\android-sdk将内容解压到 C:\\Android\\android-sdk

Navigate to C:\\Android\\android-sdk\\tools\\bin and open a command line window导航到 C:\\Android\\android-sdk\\tools\\bin 并打开命令行窗口
(shift + right click) (shift + 右键单击​​)

Run the following to download the latest android package:运行以下命令下载最新的 android 包:

sdkmanager "platforms;android-25" 

Update everything更新一切

sdkmanager --update

Other operation systems Do pretty much the same, but not using windows directories.其他操作系统几乎相同,但不使用 windows 目录。

The sdkmanager page gives more info in to what commands to use to install your sdk. sdkmanager页面提供了有关用于安装 sdk 的命令的更多信息。

Command-line approach命令行方法

mkdir android-sdk
cd android-sdk
wget https://dl.google.com/android/repository/sdk-tools-linux-*.zip
unzip sdk-tools-linux-*.zip
tools/bin/sdkmanager --update

When executing the above commands, make sure that you replace * with an appropriate version number which you could find in the download page .执行上述命令时,请确保将*替换为您可以在 下载页面中找到的适当版本号。

Installing packages安装包

You can also use the sdkmanager to list and to install any specific packages needed.您还可以使用sdkmanager列出并安装所需的任何特定软件包。

tools/bin/sdkmanager --list
tools/bin/sdkmanager "platform-tools" "platforms;android–27" "build-tools;27.0.3"

FYI供参考

sdk-tools-linux-*.zip only includes the command-line tools. sdk-tools-linux-*.zip只包含命令行工具。 This extracts content to a single directory named tools , like:这会将内容提取到名为tools的单个目录中,例如:

+- android-sdk
    +- tools

To get the SDK packages we could run:要获取 SDK 包,我们可以运行:

tools/bin/sdkmanager --update

The sdkmanager accepts the following flag: sdkmanager 接受以下标志:

--sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK 
                          containing this tool

But if we omit this flag, it assumes parent directory of tools directory as the sdk root, here in our case android-sdk directory.但是如果我们省略这个标志,它假定tools目录的父目录作为 sdk 根目录,在我们的例子中是android-sdk目录。

If you check the android-sdk folder after running tools/bin/sdkmanager --update it will be like:如果您在运行tools/bin/sdkmanager --update后检查 android-sdk 文件夹,它将类似于:

+- android-sdk
    +- tools
    +- emulator  
    +- platforms  
    +- platform-tool

If needed, also set ANDROID_HOME environment variable like:如果需要,还可以设置 ANDROID_HOME 环境变量,如:

export ANDROID_HOME=/path/to/android-sdk

What worked for me on Windows:在 Windows 上对我有用的内容:

  1. Downloaded command line tools from https://developer.android.com/studio/index.htmlhttps://developer.android.com/studio/index.html下载命令行工具
  2. Put the whole tools folder from the ZIP archive to C:\\Program Files (x86)\\Android SDK\\将 ZIP 存档中的整个tools文件夹放到C:\\Program Files (x86)\\Android SDK\\
  3. Launched tools\\android.bat as administrator, which opened the usual SDK Manager window以管理员身份启动tools\\android.bat ,这会打开通常的SDK Manager窗口
  4. Installed required components .安装所需的组件 The files were downloaded to ...\\Android SDK\\ directory (that is build-tools , platforms , platform-tools , etc. directories appeared alongside tools inside ...\\Android SDK\\ )这些文件被下载到...\\Android SDK\\目录(即build-toolsplatformsplatform-tools等目录与...\\Android SDK\\ tools一起出现)
  5. Opened the Android project in Intellij IDEA, navigated to File->Project Structure->SDKs , and added Android SDK by directing to ...\\Android SDK\\ directory在 Intellij IDEA 中打开 Android 项目,导航到File->Project Structure->SDKs ,并通过指向...\\Android SDK\\目录添加 Android SDK

This tutorial is a just step by step for installing Android SDK (Software Development Kit) assuming the user is starting from scratch.本教程是假设用户从头开始安装 Android SDK(软件开发工具包)的一步一步

There are just a couple of prerequisites to note:有几个先决条件需要注意:

  • Java runtime environment (or JDK) at Oracle website (and download the correct version (32- or 64-bit) for your computer). Oracle 网站上的Java 运行时环境(或 JDK)(并为您的计算机下载正确的版本(32 位或 64 位))。
  • A good internet connection (needed for downloading system images etc)良好的互联网连接(需要下载系统映像等)

I recommed using the offline SDK installer for installing the essential tools namely SDK and AVD manager: The last version of he installer is found here: SDK Installer_r24.4.1 (for windows),SDK Installer_r24.4.1 (for linux) or SDK Installer_r24.4.1 (for macos)我推荐使用离线 SDK 安装程序来安装必要的工具,即 SDK 和 AVD 管理器:他的安装程序的最新版本位于: SDK Installer_r24.4.1 (适用于 Windows)、SDK Installer_r24.4.1 (适用于 linux)或SDK Installer_r24.4.1 (对于 macos)

For this guide I was using windows :对于本指南,我使用的是windows

Here is the workthrough:这是解决方法:

  • Depending on your choice download the appropriate SDK package from above links (but for this example I will be using the manual method)根据您的选择,从上面的链接下载适当的 SDK 包(但对于本示例,我将使用手动方法)
  • After downloading the package, begin installation (and choose the desired installation folder to proceed or just leave the default %USERPROFILE%\\android-sdk ):下载软件包后,开始安装(并选择所需的安装文件夹继续或保留默认的%USERPROFILE%\\android-sdk ):

在此处输入图片说明

  • When done leave the option to download system images "checked":完成后,保留“选中”下载系统映像的选项:

在此处输入图片说明

Now we're in business...现在我们在做生意...

  • The SDK manager window will appear, now you need to update/download other sdk packages (ie platform-tools, system-images, platforms etc according to API levels)将出现 SDK 管理器窗口,现在您需要根据 API 级别更新/下载其他 sdk 包(即平台工具、系统映像、平台等)

在此处输入图片说明

Note: I recommend downloading x86 images as they're much faster tham arm counterparts, also get intel HAXM (hardware accelerated execution manager) driver to significantly increase your emulator speed注意:我建议下载 x86 映像,因为它们比 arm 对应的要快得多,还可以使用英特尔 HAXM(硬件加速执行管理器)驱动程序来显着提高模拟器速度

  • All set, now you just need to create and configure an Android virtual device matching your target Android version and tweak desired settings.一切就绪,现在您只需要创建和配置一个与您的目标 Android 版本匹配的 Android 虚拟设备并调整所需的设置。

  • To do this click on the Tools tab in SDK manager and select manage AVDs, then in the following window click Create you'll see a similar screen as below:为此,请单击 SDK 管理器中的工具选项卡并选择管理 AVD,然后在以下窗口中单击创建,您将看到如下所示的类似屏幕:

在此处输入图片说明

  • After that boot the newly created virtual device.之后启动新创建的虚拟设备。

在此处输入图片说明

  • Install applications and test as you wish ..安装应用程序并根据需要进行测试..

Well the folks who are trying to download either on *ix or Ec2 machine would suggest to clean approach in below steps:那么尝试在 *ix 或 Ec2 机器上下载的人会建议按照以下步骤清理方法:

$ mkdir android-sdk
$ cd android-sdk
$ mkdir cmdline-tools
$ cd cmdline-tools
$ wget https://dl.google.com/android/repository/commandlinetools-linux-*.zip
$ unzip commandlinetools-linux-*.zip

The king - sdkmanager lives inside国王 - sdkmanager 住在里面

cmdline-tools/tools/bin命令行工具/工具/bin

, you'd better set in PATH environment variable. ,你最好在PATH环境变量中设置。

but cmdline-tools should not be set as ANDROID_HOME .cmdline-tools不应设置为ANDROID_HOME Because later, when updating Android SDK, or installing more packages, the other packages will be placed under ANDROID_HOME , but not under cmdline-tools .因为以后更新Android SDK,或者安装更多的包时,其他包会放在ANDROID_HOME下,而不是cmdline-tools

The final, complete ANDROID_HOME directory structure should look like below, consist of quite a few sub-directories:最终完整的 ANDROID_HOME 目录结构应如下所示,包含相当多的子目录:

build-tools, cmdline-tools, emulator, licenses, patcher, platform-tools, platforms, tools . build-tools, cmdline-tools, emulator, licenses, patcher, platform-tools, platforms, tools You can easily point out that build-tools and cmdline-tools are siblings, all resides inside the parent ANDROID_HOME.你可以很容易地指出build-toolscmdline-tools是兄弟姐妹,都驻留在父 ANDROID_HOME 中。

Add SDK tools directory in PATH environment variable to make executable available globally.在 PATH 环境变量中添加 SDK 工具目录以使可执行文件全局可用。 Add below line either in ~/.bashrc or ~/.profile file to make it permanent.~/.bashrc~/.profile文件中添加以下行以使其永久化。

In order to edit the ~/.bashrc simply can be editable in vim mode为了编辑~/.bashrc可以在 vim 模式下简单地编辑

$ vim .bashrc

Now set your preferred ANDROID_HOME in .bashrc file :现在在.bashrc文件中设置您首选的ANDROID_HOME

export ANDROID_HOME=/home/<user>/android-sdk
export PATH=${PATH}:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools

here strange thing that we haven't download the platform-tools directory as of now but mentoning it under path but let it be as it will help you avoid remodification on the same file later.奇怪的是,我们现在还没有下载platform-tools目录,而是在 path 下提及它,但让它保持原样,因为它会帮助您避免以后对同一文件进行重新修改。

Now go inside the same directory:现在进入同一个目录:

$ cd android-sdk

NOTE : well in first attempt sdkmanager command didnt found for me so I close the terminal and again created the connection or you can also refresh the same if it works for you. NOTE :在第一次尝试时没有为我找到 sdkmanager 命令,所以我关闭了终端并再次创建了连接,或者如果它对你有用,你也可以刷新它。

after that use the sdkmanager to list and install the packages needed:之后,使用 sdkmanager 列出并安装所需的软件包:

$ sdkmanager "platform-tools" "platforms;android-27" "build-tools;27.0.3"

Hence Sdkmanager path is already set it will be accessible from anywhere:因此 Sdkmanager 路径已经设置好,可以从任何地方访问:

$ sdkmanager --update


$ sdkmanager --list
Installed packages:=====================] 100% Computing updates...             
  Path                 | Version | Description                    | Location             
  -------              | ------- | -------                        | -------              
  build-tools;27.0.3   | 27.0.3  | Android SDK Build-Tools 27.0.3 | build-tools/27.0.3/  
  emulator             | 30.0.12 | Android Emulator               | emulator/            
  patcher;v4           | 1       | SDK Patch Applier v4           | patcher/v4/          
  platform-tools       | 30.0.1  | Android SDK Platform-Tools     | platform-tools/      
  platforms;android-27 | 3       | Android SDK Platform 27        | platforms/android-27/

For those using the latest distribution on windows, the following should be enough:对于那些在 windows 上使用最新发行版的人来说,以下内容应该足够了:

  1. Download the command line tools from here这里下载命令行工具
  2. Extract it somewhere (eg C:\\androidsdk )将其提取到某处(例如C:\\androidsdk
  3. Add ANDROID_SDK_TOOLS as environment variable pointing to where you extracted it ( C:\\androidsdk )添加ANDROID_SDK_TOOLS作为指向您提取它的位置的环境变量( C:\\androidsdk
  4. Create a folder named latest inside the cmdlime-tools you extracted.在您提取的cmdlime-tools 中创建一个名为latest的文件夹。 And move what's inside(bin,lib...) to the folder latest .并将里面的内容(bin,lib...) 移动到文件夹latest
  5. cd cmdline-tools/latest/bin and execute the following: cd cmdline-tools/latest/bin并执行以下命令:

sdkmanager.bat system-images;android-29;default;x86_64 platforms;android-29 build-tools;29.0.3 extras;google;m2repository extras;android;m2repository

  1. Agree to the terms and conditions and continue.同意条款和条件并继续。 voilà

Command line only without sdkmanager (for advanced users / CI):没有sdkmanager命令行(适用于高级用户 / CI):

You can find the download links for all individual packages, including various revisions, in the repository XML file: https://dl.google.com/android/repository/repository-12.xml您可以在存储库 XML 文件中找到所有单个包(包括各种修订版)的下载链接: https : //dl.google.com/android/repository/repository-12.xml

(where 12 is the version of the repository index and will increase in the future). (其中 12 是存储库索引的版本,将来会增加)。

All <sdk:url> values are relative to https://dl.google.com/android/repository , so所有<sdk:url>值都相对于https://dl.google.com/android/repository ,所以

<sdk:url>platform-27_r03.zip</sdk:url>

can be downloaded at https://dl.google.com/android/repository/platform-27_r03.zip可以在https://dl.google.com/android/repository/platform-27_r03.zip下载

Similar summary XML files exist for system images as well:系统映像也存在类似的摘要 XML 文件:

可悲的是,如果您的公司防火墙阻止其他来源,您将直接从谷歌下载, 2009 年 9 月 1.6 版 r1是他们拥有的最新 SDK。

If you are using windows, then this post may help. 如果您使用的是Windows,则此帖子可能会有所帮助。 It was writen for windows 10 but i think it can be apply on a windows 8 pc Install Android SDK on Windows 10 without Android Studio 它是为Windows 10写的,但我认为它可以适用于Windows 8 pc 在没有Android Studio的Windows 10上安装Android SDK

To download the SDK over command line, the link has changed slightly than previously mentioned:要通过命令行下载 SDK,链接比之前提到的略有变化:

wget --quiet --output-document=/tmp/sdk-tools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}.zip

Latest version listed on the downloads page . 下载页面上列出了最新版本。

Install latest version from CLI without specifying version从 CLI 安装最新版本而不指定版本

Here is an approach to downloading the last version of the Android SDK from CLI.这是从 CLI 下载 Android SDK 最新版本的方法。

First of all, create and move to the following dir:首先,创建并移动到以下目录:

mkdir -p ~/android-sdk/cmdline-tools
cd ~/android-sdk/cmdline-tools

Then download the SDK (it basically finds the download URL from the HTML and downloads it, if you go to the web page, you'll see that it only shows the last one, so it works): Then download the SDK (it basically finds the download URL from the HTML and downloads it, if you go to the web page, you'll see that it only shows the last one, so it works):

curl -s https://developer.android.com/studio\#command-tools | grep -Eo 'https://dl.google.com/android/repository/commandlinetools-mac-[0-9]*_latest.zip' | head -n 1 | xargs wget

Unzip file解压文件

ls -A1 | xargs unzip

I downloaded Android Studio and installed it.我下载了 Android Studio 并安装了它。 The installer said:-安装人员说:-

Android Studio => ( 500 MB ) Android Studio => ( 500 MB )

Android SDK => ( 2.3 GB ) Android SDK => ( 2.3 GB )

Android Studio installer is actually an "Android SDK Installer" along with a sometimes useful tool called "Android Studio". Android Studio 安装程序实际上是一个“Android SDK 安装程序”以及一个有时有用的工具,称为“Android Studio”。

Most importantly:- Android Studio Installer will not just install the SDK.最重要的是:- Android Studio 安装程序不仅会安装 SDK。 It will also:-它还将:-

  • Install the latest build-tools.安装最新的构建工具。
  • Install the latest platform-tools.安装最新的平台工具。
  • Install the latest AVD Manager which you cannot do without.安装您离不开的最新 AVD 管理器。

Things which you will have to do manually if you install the SDK from its zip file.如果从 zip 文件安装 SDK,则必须手动执行这些操作。

Just take it easy.放轻松吧。 Install the Android Studio .安装 Android Studio

****************************** Edit ****************************** ********************************编辑******************** ***********

So, being inspired by the responses in the comments I would like to update my answer.因此,受到评论中回复的启发,我想更新我的答案。

The update is that only (and only) if 500MB of hard disk space does not matter much to you than you should go for Android Studio otherwise other answers would be better for you.更新是只有(并且仅)如果 500MB 的硬盘空间对您来说并不重要,那么您应该选择 Android Studio,否则其他答案对您来说会更好。

Android Studio worked for me as I had a 1TB hard disk which is 2000 times 500MB. Android Studio 为我工作,因为我有一个 1TB 的硬盘,它是 500MB 的 2000 倍。

Also, note: that RAM sizse should not a restriction for you as you would not even be running Android Studio.另外,请注意: RAM 大小不应该对您构成限制,因为您甚至不会运行 Android Studio。

I came to this solution as I was myself stuck in this problem.我来到这个解决方案是因为我自己被这个问题困住了。 I tried other answers but for some reason (maybe my in-competencies) they did not work for me.我尝试了其他答案,但由于某种原因(可能是我的能力不足),它们对我不起作用。 I decided to go for Android Studio and realized that it was merely 18% of the total installation and SDK was 82% of it.我决定使用 Android Studio 并意识到它仅占总安装量的 18%,而 SDK 占总安装量的 82%。 While I used to think otherwise.虽然我以前不这么认为。 I am not deleting the answers inspite of negative rating as the answer worked for me.尽管答案对我有用,但我不会删除负面评价的答案。 I might work for someone elese with a 1 TB hard disk (which is pretty common these days).我可能会为拥有 1 TB 硬盘的其他人工作(这在当今很常见)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不下载 Android Studio 的情况下下载 Android SDK 和工具? - How can I download the Android SDK and Tools without downloading Android Studio? 如何在没有 Visual Studio 的情况下下载 Android SDK? - How to download Android SDK without Visual Studio? 如何在没有SDK的情况下“下载”Android Studio IDE? - How to “download” Android Studio IDE without the SDK? 如何在 Android Studio 中配置 SDK - How do I configure SDK in Android studio 如何在不等待sdk manager下载的情况下下载android studio离线sdk? - How to download android studio offline sdk without waiting sdk manager to download it? 如何在 Android Studio 中“选择 Android SDK”? - How do I “select Android SDK” in Android Studio? "如何在 Android Studio 中“选择 Android SDK”?" - How do I "select Android SDK" in Android Studio? 如何卸载Android Studio和Android SDK? - How do I uninstall Android Studio and the Android SDK? 如何配置为使用系统上已经安装的Android SDK,而不通过“安装新软件”下载Eclipse软件包? - How do I configure to use the Android SDK already installed on my system without downloading the Eclipse packages via “Install New Software”? 如何在不下载Android AOSP的情况下为Android 9下载libxml2.so - How to download libxml2.so for android 9 without downloading android aosp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM