Android SDK location

后端 未结 15 1610
一整个雨季
一整个雨季 2020-11-28 05:48

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

相关标签:
15条回答
  • 2020-11-28 06:00

    If you have downloaded sdk manager zip (from https://developer.android.com/studio/#downloads), then you have Android SDK Location as root of the extracted folder.

    So silly, But it took time for me as a beginner.

    0 讨论(0)
  • 2020-11-28 06:06

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

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

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

    In visual Studio :

    Note : you should not use Program Files path to install Android Studio due to the space in path !

    0 讨论(0)
  • 2020-11-28 06:11

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

    For example, I have installed the SDK in c:\spool\Android and for me running the sdkmanager --verbose --list looks like:

    >sdkmanager --list --verbose
    Info: Parsing c:\spool\Android\build-tools\27.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\27.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.

    0 讨论(0)
  • 2020-11-28 06:12

    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.

    0 讨论(0)
  • 2020-11-28 06:12

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

    0 讨论(0)
  • 2020-11-28 06:12

    The question doesn't seem to require a 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.

    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.

    0 讨论(0)
提交回复
热议问题