Skip to content

Commit fb95edd

Browse files
[Xamarin.Android.Tools.AndroidSdk] Add Android Studio's Android SDK paths (#266)
We already had code looking for this path on macOS: ~/Library/Android/sdk This is where Android Studio installs its Android SDK. Unfortunately, windows is at `%localappdata%\Android\Sdk` and we had no code looking for it! I also added a path for Linux. This will also do a `Directory.Exists()` check before returning the new paths. We will also have to probe for these locations *last* to preserve existing behavior.
1 parent ca74eba commit fb95edd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkUnix.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,14 @@ protected override IEnumerable<string> GetAllAvailableAndroidSdks ()
111111
}
112112

113113
// Check some hardcoded paths for good measure
114+
// macOS: ~/Library/Android/sdk
114115
var macSdkPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), "Library", "Android", "sdk");
115-
yield return macSdkPath;
116+
if (Directory.Exists (macSdkPath))
117+
yield return macSdkPath;
118+
// Linux: ~/Android/Sdk
119+
var linuxSdkPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.UserProfile), "Android", "Sdk");
120+
if (Directory.Exists (linuxSdkPath))
121+
yield return linuxSdkPath;
116122
}
117123

118124
protected override string GetShortFormPath (string path)

src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkWindows.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ protected override IEnumerable<string> GetAllAvailableAndroidSdks ()
106106
: Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFiles), "Android", "android-sdk"),
107107
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "Android", "android-sdk"),
108108
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData), "Android", "android-sdk"),
109+
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "Android", "Sdk"),
109110
};
110111
foreach (var basePath in paths)
111112
if (Directory.Exists (basePath))

0 commit comments

Comments
 (0)