Skip to content

ResolveSdks should also look for ANDROID_SDK_ROOT #2979

Closed

Description

@savornicesei

Steps to Reproduce

Consider a build server configuration on a Windows 10 machine:

  1. Have only Visual Studio 2017 Build Tools installed, including Mobile build tools
  2. Install AndroidSDK from zip file
  3. Set ANDROID_SDK_ROOT as described here
  4. Build an android xamarin project using MsBuild

Expected Behavior

The project should be succesfully build

Actual Behavior

Build fails with C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(703,2): error XA5300: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory.

The workaround is to set the Android SDK Tools registry key

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Android SDK Tools]
"Path"="C:\\Program Files (x86)\\Android\\android-sdk"
"StartMenuGroup"="Android SDK Tools"

By looking into the AndroidSdkWindows class I saw that it only checks the registry for specific keys and then checks for some hardcoded paths. Why not checking the ANDROID_SDK_ROOT?

Thanks,
Simo

Activity

  1. jonathanpeppers commented on Apr 16, 2019

    @jonathanpeppers
    Member

    @savornicesei can you just use AndroidSdkDirectory? Xamarin.Android fully embraces MSBuild so you can use this two ways:

    msbuild foo.android.csproj /p:AndroidSdkDirectory=C:\android-sdk
    

    Or via an AndroidSdkDirectory environment variable set to your desired value. All MSBuild properties can be set via environment variables.

  2. savornicesei commented on Apr 17, 2019

    @savornicesei
    Author

    Hi @jonathanpeppers
    I've passed it along but it didn't seemed to be picked up. I will have to prepare some test to look at it more closely.
    Still I expected .NET env. (MSBuild) to pick up the ANDROID_SDK_ROOT, as it checks the Android SDK Tools registry key that seems to be set by the Android SDK installer.
    I actually expected ANDROID_SDK_ROOT to take precedence over any other reg key.

    Best,
    Simo

  3. jonathanpeppers commented on Apr 17, 2019

    @jonathanpeppers
    Member

    Can you attach a diagnostic MSBuild log of your build? Or if it is just as easy for you, an MSBuild binary log would be even better.

    Still I expected .NET env. (MSBuild) to pick up the ANDROID_SDK_ROOT, as it checks the Android SDK Tools registry key that seems to be set by the Android SDK installer.
    I actually expected ANDROID_SDK_ROOT to take precedence over any other reg key.

    I think this part is a feature request you should submit on the Visual Studio Developer Community, so other people in the community can vote on it. Pull requests are also welcome! 😄

  4. added
    need-info
    on Jun 24, 2019
  5. jonathanpeppers commented on Jun 24, 2019

    @jonathanpeppers
    Member

    Closing for now, let us know if you have a log and we can see why /p:AndroidSdkDirectory isn't working for you. Thanks!

  6. ghost locked as resolved and limited conversation to collaborators on Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

need-infoquestion

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions