Android SDK 位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25176594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:11:13  来源:igfitidea点击:

Android SDK location

androidsdkxamarin-studio

提问by user3736648

I have Xamarin Studio, and I need to specify the Android SDK Location. I have previously had Xamarin Studio working on my pc, and for some reason, I need to enter this again.

我有 Xamarin Studio,我需要指定 Android SDK 位置。我以前在我的电脑上使用过 Xamarin Studio,由于某种原因,我需要再次输入。

I have entered the following location:

我输入了以下位置:

C:\Users\**username**\AppData\Local\Android\android-sdk

C:\Users\**username**\AppData\Local\Android\android-sdk

Xamarin Studio does not accept this location and displays the following message:

Xamarin Studio 不接受此位置并显示以下消息:

No SDK found at the specified location

This location has platform-tools and other SDK folders.

这个位置有平台工具和其他 SDK 文件夹。

Why is this not working, and what should I do?

为什么这不起作用,我该怎么办?

采纳答案by Chris

Do you have a screen of the content of your folder? This is my setup:

你有你的文件夹内容的屏幕吗?这是我的设置:

Xamarin

沙马林

Folder

文件夹

I hope these screenshots can help you out.

我希望这些截图可以帮助你。

回答by luckyging3r

Update v3.3

更新 v3.3

enter image description here

在此处输入图片说明

Update:

更新:

Android Studio 3.1 update, some of the icon images have changed. Click this icon in Android Studio.

Android Studio 3.1 更新,部分图标图片已更改。在 Android Studio 中单击此图标。

enter image description here

在此处输入图片说明

Original:

原来的:

Click this icon in Android Studio for the Android SDK manager

在 Android Studio 中单击此图标以获取 Android SDK 管理器

enter image description here

在此处输入图片说明

And your Android SDK Location will be here enter image description here

您的 Android SDK 位置将在此处 在此处输入图片说明

回答by busetekin

The Android SDK path is usually C:\Users\<username>\AppData\Local\Android\sdk.

Android SDK 路径通常是C:\Users\<username>\AppData\Local\Android\sdk.

回答by Raj Asapu

Try to open the Android Sdk manager and the path would be displayed on the status bar.

尝试打开 Android Sdk 管理器,路径将显示在状态栏上。

enter image description here

在此处输入图片说明

回答by Pankaj

The default location for Android sdk(s) on a Mac is:

Mac 上 Android sdk 的默认位置是:

/Users/*username*/Library/Android/sdk

/Users/*username*/Library/Android/sdk

回答by scrat789

If you only installed Xamarinwith Visual Studio setup, the android SDK location is :

如果您仅使用 Visual Studio 安装程序安装Xamarin,则 android SDK 位置为:

C:\Program Files (x86)\Android\android-sdk

You can find it in Android SDK Manager as said Raj Asapu

你可以在 Android SDK Manager 中找到它,如Raj Asapu 所说

In visual Studio : Android SDK Manger from Visual Studio

在视觉工作室: 来自 Visual Studio 的 Android SDK 管理器

Note : you should not use Program Files path to install Android Studiodue to the space in path ! Android studio setup after Xamarin

注意:由于路径中有空格,您不应该使用 Program Files 路径来安装Android StudioXamarin 之后的 Android Studio 设置

回答by Constantin Zagorsky

On 28 April 2019 official procedure is the following:

2019 年 4 月 28 日的官方程序如下:

  1. Download and install Android Studio from - link
  2. Start Android Studio. On first launch, the Android Studio will download latest Android SDK into officially accepted folder
  3. When Android studio finish downloading components you can copy/paste path from the "Downloading Components" view logs so you don't need to type your [Username]. For Windows: "C:\Users\ [Username] \AppData\Local\Android\Sdk"
  1. 从 -链接下载并安装 Android Studio
  2. 启动安卓工作室。首次启动时,Android Studio 会将最新的 Android SDK 下载到官方接受的文件夹中
  3. 当 Android Studio 完成组件下载后,您可以从“下载组件”视图日志中复制/粘贴路径,这样您就无需输入您的 [用户名]。对于 Windows:“ C:\Users\ [用户名] \AppData\Local\Android\Sdk

回答by ArtemGr

If you can run the "sdkmanager" from the command line, then running sdkmanager --verbose --listwill reveal the paths it checks.

如果您可以从命令行运行“sdkmanager”,那么运行sdkmanager --verbose --list将显示它检查的路径。

For example, I have installed the SDK in c:\spool\Androidand for me running the sdkmanager --verbose --listlooks like:

例如,我已经安装了 SDKc:\spool\Android并且运行sdkmanager --verbose --list如下:

enter image description here

在此处输入图片说明

>sdkmanager --list --verbose
Info: Parsing c:\spool\Android\build-tools.0.3\package.xml
Info: Parsing c:\spool\Android\emulator\package.xml
Info: Parsing c:\spool\Android\extras\android\m2repository\package.xml
Info: Parsing c:\spool\Android\extras\intel\Hardware_Accelerated_Execution_Manager\package.xml
Info: Parsing c:\spool\Android\patcher\v4\package.xml
Info: Parsing c:\spool\Android\platform-tools\package.xml
Info: Parsing c:\spool\Android\platforms\android-27\package.xml
Info: Parsing c:\spool\Android\tools\package.xml
Installed packages:=====================] 100% Computing updates...
--------------------------------------
build-tools;27.0.3
    Description:        Android SDK Build-Tools 27.0.3
    Version:            27.0.3
    Installed Location: c:\spool\Android\build-tools.0.3

P.S. On another PC I let the Android Studio install the Android SDK for me, and the SDK ended up in C:\Users\MyUsername\AppData\Local\Android\Sdk.

PS 在另一台 PC 上,我让 Android Studio 为我安装了 Android SDK,SDK 最终以C:\Users\MyUsername\AppData\Local\Android\Sdk.

回答by Riveria Kid

Have you tried to find this folder via the Windows explorer? Can it been seen? Maybe the folder is hidden (by default install - it is hidden by the Windows operating system in the users folder). Just check that you can view hidden folders in Windows explorer (by the settings in the windows control panel > appearance and personalization > folder options > show hidden files and folders.

您是否尝试过通过 Windows 资源管理器找到此文件夹?可以看到吗?也许该文件夹是隐藏的(默认情况下安装 - 它被 Windows 操作系统隐藏在用户文件夹中)。只需检查您是否可以在 Windows 资源管理器中查看隐藏文件夹(通过 Windows 控制面板中的设置 > 外观和个性化 > 文件夹选项 > 显示隐藏文件和文件夹。

This happened to me as the Windows OS could not find the SDK folder which was required for the Android Studio SDK path, and was resolved by showing hidden files and folders, which enabled me to complete the default SDK install path location.

这发生在我身上,因为 Windows 操作系统找不到 Android Studio SDK 路径所需的 SDK 文件夹,并通过显示隐藏文件和文件夹来解决,这使我能够完成默认的 SDK 安装路径位置。

回答by monkey0506

The question doesn't seem to requirea programmatic solution, but my Google search brought me here anyway. Here's my C# attempt at detecting where the SDK is installed, based on the most common installation paths.

这个问题似乎不需要程序化的解决方案,但无论如何我的谷歌搜索把我带到了这里。这是我的 C# 尝试,根据最常见的安装路径检测 SDK 的安装位置。

static string FindAndroidSDKPath()
{
    string uniqueFile = Path.Combine("platform-tools", "adb.exe"); // look for adb in Android folders
    string[] searchDirs =
    {
        // User/AppData/Local
        Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
        // Program Files
        Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles),
        // Program Files (x86) (it's okay if we're on 32-bit, we check if this folder exists first)
        Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + " (x86)",
        // User/AppData/Roaming
        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    };
    foreach (string searchDir in searchDirs)
    {
        string androidDir = Path.Combine(searchDir, "Android");
        if (Directory.Exists(androidDir))
        {
            string[] subDirs = Directory.GetDirectories(androidDir, "*sdk*", SearchOption.TopDirectoryOnly);
            foreach (string subDir in subDirs)
            {
                string path = Path.Combine(subDir, uniqueFile);
                if (File.Exists(path))
                {
                    // found unique file at DIR/Android
                    return subDir;
                }
            }
        }
    }
    // no luck finding SDK! :(
    return null;
}

I need this because I'm writing an extension to a C# program to work with Android Studio/Gradle. Hopefully someone else will find this approach useful.

我需要这个,因为我正在为 C# 程序编写扩展以与 Android Studio/Gradle 一起使用。希望其他人会发现这种方法很有用。