You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A fresh install of Android and VS Code fails #8522
I just did a fresh install of VS Code and tried to build an Android app. I followed the instructions to set up Java and the Android SDK. VSCode can build the app, but dotnet build does not.
It fails because it can't find the sdk because I have not set AndroidSdkDirectory. I never set that for builds when using full VS.
I tried setting the correct ANDROID_SDK_ROOT and ANDROID_HOME envvars, but nothing changes.
The output of dotnet build -t:InstallAndroidDependencies -f:net8.0-android also does not say anything. It would be nice if the SDK could be automatically picked up using the default/accepted envvars and not require a .NET-specific setting.
Steps to Reproduce
Clean VS/Sandbox
Install MAUI Dev Kit
Install Java and Android SDK following the directions
Run dotnet build
Observe the error
Run using F5
Observe no error
Did you find any workaround?
Setting an envvar AndroidSdkDirectory to my SDK. This is not really expected and no mention in the docs. I just know to set it because I know MSBuild also checks envvars.
This is also an issue because this breaks VS Code intellisense. The design time builds are failing since android is the first TFM. As a result, a fresh VS Code does not work.
We should probably move this issue to the andorid-sdk-installer repo as that is where the task in question lives.
That said we should also update the documentation in this repo for this target to say that the AndroidSdkDirectory is required. Currently it doesn't mention it at all.
But, if I install VS proper and then dotnet build it works, why? I tested now in a plain pwsh prompt after installing VS, no AndroidSdkDirectory envvar needed.
But, if I install VS proper and then dotnet build it works, why? I tested now in a plain pwsh prompt after installing VS, no AndroidSdkDirectory envvar needed.
Because the IDE extension for .net android passes that value for 'AndroidSdkDirectory' to the target when it calls it.
Its funny I thought this was done by the VSCode Maui extension , I seem to remember someone talking about this issue.
And maybe mention that there are some special paths so just in case there is some weird case where different devs use different paths and get different results.
But, a free win might just be to rename Sdk to android-sdk?
Activity
mattleibow commentedon Nov 19, 2023
This is also an issue because this breaks VS Code intellisense. The design time builds are failing since android is the first TFM. As a result, a fresh VS Code does not work.
dellis1972 commentedon Nov 20, 2023
We should probably move this issue to the
andorid-sdk-installerrepo as that is where the task in question lives.That said we should also update the documentation in this repo for this target to say that the
AndroidSdkDirectoryis required. Currently it doesn't mention it at all.mattleibow commentedon Nov 20, 2023
What was the issue for also checking the ANDROID_SDK_ROOT or ANDROID_HOME paths as that is a "standard" envvar?
dellis1972 commentedon Nov 20, 2023
@mattleibow it was never implemented as both VS and VSForMac always provided a valid to the msbuild property.
mattleibow commentedon Nov 20, 2023
But, if I install VS proper and then dotnet build it works, why? I tested now in a plain pwsh prompt after installing VS, no
AndroidSdkDirectoryenvvar needed.dellis1972 commentedon Nov 20, 2023
Because the IDE extension for .net android passes that value for 'AndroidSdkDirectory' to the target when it calls it.
Its funny I thought this was done by the VSCode Maui extension , I seem to remember someone talking about this issue.
dellis1972 commentedon Nov 20, 2023
or maybe the VS installer is setting up a system level envvar.
akoeplinger commentedon Nov 20, 2023
I think on Windows there's this lookup logic that also checks a reg key set by VS: https://github.com/xamarin/xamarin-android-tools/blob/8d382816bdd3b62107704dbab47dabd43d4a997c/src/Xamarin.Android.Tools.AndroidSdk/Sdks/AndroidSdkWindows.cs#L82-L107
mattleibow commentedon Nov 20, 2023
OK, so on my machine, the checked paths are:
However, the recommended path is:
They are so close, maybe the docs can rather say:
And maybe mention that there are some special paths so just in case there is some weird case where different devs use different paths and get different results.
But, a free win might just be to rename
Sdktoandroid-sdk?akoeplinger commentedon Nov 21, 2023
I think
%LOCALAPPDATA%\Android\Sdkis the default install location that Android Studio uses. We should probably add that to the lookup path.[Xamarin.Android.Build.Tasks] Update XA5207 for VSCode (#8494)
[Xamarin.Android.Build.Tasks] Update XA5207 for VSCode (#8494)
akoeplinger commentedon Apr 14, 2025
is this still an issue?