Skip to content

Commit 9f4ed4b

Browse files
Sergey Shakhnazarovjonpryor
authored andcommitted
Use %ProgramW6432% path for 32-bit apps (#75)
Context: https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details#environment-variables Use the `%ProgramW6432%` environment variable (if available) so that both **Prefer 32-bit**=false and **Prefer 32-bit**=true apps can get the path. Otherwise `Environment.SpecialFolder.ProgramFiles` returns `"C:\Program Files (x86)"` for 32-bit apps on 64-bit OS, which is not where the Android SDK is installed, and thus path lookup fails.
1 parent 294f447 commit 9f4ed4b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ protected override IEnumerable<string> GetAllAvailableAndroidSdks ()
9393
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "Xamarin", "MonoAndroid", "android-sdk-windows"),
9494
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86), "Android", "android-sdk"),
9595
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86), "Android", "android-sdk-windows"),
96-
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFiles), "Android", "android-sdk"),
96+
!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("ProgramW6432"))
97+
? Path.Combine (Environment.GetEnvironmentVariable ("ProgramW6432"), "Android", "android-sdk")
98+
: Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFiles), "Android", "android-sdk"),
9799
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.LocalApplicationData), "Android", "android-sdk"),
98100
Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData), "Android", "android-sdk"),
99101
@"C:\android-sdk-windows"

0 commit comments

Comments
 (0)