Redth / AndroidSdk.Tools

.NET Library + global tool for various Android SDK Manager, ADB, AVD, Emulator commands
MIT License
53 stars 11 forks source link

"System.IO.FileNotFoundException: Could not find adb" error message. #4

Open JamestsaiTW opened 1 year ago

JamestsaiTW commented 1 year ago

I get this error message when I try to use MAUI.UITesting.

I trace it and why I got this error from: https://github.com/Redth/AndroidSdk.Tools/blob/master/AndroidSdk/AndroidSdkManager.cs

static string[] KnownLikelyPaths =>
            RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
new string[] {
    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Android", "android-sdk"),
    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Android", "android-sdk"),
} :
new string []
{
    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Developer", "android-sdk-macosx"),
    Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Developer", "Xamarin", "android-sdk-macosx"),
    Path.Combine("Developer", "Android", "android-sdk-macosx"),
};

(Just test it on Windows) Because my "Android-SDK" don't install at "Environment.SpecialFolder.ProgramFiles", so I got this error.
When I move my "Android-SDK" folder to "Environment.SpecialFolder.ProgramFiles", it works well.

(All platform) So, I suggest it can throw a detail exception message for user, even allow us can pass custom path for "Android-SDK" folder to the library, thanks.

igotinfected commented 1 year ago

Exact same issue here, trying to use MAUI.UITesting but I have my android SDK installed on a second drive.