How can I fix UI Testing for an Android Emulator on VS?

I am continually getting this error upon StartApp(); in the AppInitializer.cs file in my UI Testing suite:
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.

I have set the ANDROID_HOME environment variable to the location of my Android SDK package through the command line. If I echo ANDROID_HOME in my command line, it returns the path to my Android SDK. Why can Visual Studio not find my Android SDK package and how can I fix this issue?

Best Answer

  • hkiddhkidd ✭✭ ✭✭
    edited June 2018 Accepted Answer

    @JGoldberger Thanks for your help! I am working on Windows, and the issue is with the tools/emulator to emulator/emulator file path change. According to Visual Studio, this issue will be fixed in an upcoming release. The solution for now is to start the Android emulator through the device manager and then the application can be deployed. The ANDROID_HOME variable had to be set through Control Panel as well.

Answers

  • JGoldbergerJGoldberger Xamurai USMember, Forum Administrator, Xamarin Team, University Xamurai

    @hkidd

    Are you working on Windows or Mac? I will assume Mac for now as I am not sure this needs to even be set on Windows.

    Did you set ANDROID_HOME in your .bash_profile file or are you setting it manually? If you set that in a bash session, it is only available in that bash session. If you want it to be always available, you need to export the variable in .bash_profile

    try the following:

    1. Open Terminal
    2. enter the command nano .bash_profile
    3. Arrow down to the end of the file
    4. Enter the following, replacing pathToAndroidSDK with the actual absolute path (i.e. starts with / ) to your Android SDK folder:

      export ANDROID_HOME="pathToAndroidSDK"

    5. Press CTL-o to write the changes to the file

    6. Press CTL-x to quit the nano text editor.

    Once that is done, the ANDROID_HOME variable should always be available.

  • hkiddhkidd ✭✭ Member ✭✭
    edited June 2018 Accepted Answer

    @JGoldberger Thanks for your help! I am working on Windows, and the issue is with the tools/emulator to emulator/emulator file path change. According to Visual Studio, this issue will be fixed in an upcoming release. The solution for now is to start the Android emulator through the device manager and then the application can be deployed. The ANDROID_HOME variable had to be set through Control Panel as well.

Sign In or Register to comment.