I am attempting to get some UITests set up for my project, and am receiving an error when running them:
System.Exception : Android SDK not found. Please install it and if it is still not located, please set the ANDROID_HOME environment variable to point to the directory.
Searched locations:
Windows Registry
(No path) - Not set. [ Source: ANDROID_HOME ]
at Xamarin.UITest.Shared.Dependencies.AndroidSdkFinder.GetTools()
at Xamarin.UITest.Shared.Android.DefaultAndroidFactory.BuildExecutor(IProcessRunner processRunner)
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration, IExecutor executor)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at project.UITest.AppInitializer.StartApp(Platform platform) in C:\Users\Jason\source\repos\project\project.UITest\AppInitializer.cs:line 16
at StarTracker.UITest.Tests.BeforeEachTest() in C:\Users\Jason\source\repos\project\project.UITest\Tests.cs:line 25
When I run my project in Debug mode, the emulator loads without issues, so Visual Studio definitely knows where my Android SDK is. From another post for a different IDE, I added the "ANDROID_HOME" variable and pointed it to C:\Users\Jason\.android\
and C:\Program Files (x86)\Android\android-sdk\
, but receive the same error.
This occurs if the emulator is already running, or if I'm depending on the UITest to start the emulator.
How do I fix this error?
Doing some further research, I found the following post on a Microsoft Visual Studio page that explicitly calls out the SDK not found error while running UITest: https://www.360logica.com/blog/how-to-set-path-environmental-variable-for-sdk-in-windows/. After following those steps, I had to restart my computer (commands to re-enable the environmental variables without restarting didn't work).
After restarting, I started to receive an JDK not found error. For that, I found https://www.codejava.net/java-core/how-to-set-java-home-environment-variable-on-windows-10, which is basically the same steps, just pointing to the Microsoft JDK from Visual Studio.
Restarting again allowed me to begin my UITesting.