dotnet / dotnet/android

A fresh install of Android and VS Code fails

Open
#8,522 11 comments 0 reactions 2 assignees Claimed by @jonathanpeppers View on GitHub
Area: App+Library Build
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 19h
Merged PRs (30d)
252

Description

### Android application type

.NET Android (net7.0-android, etc.)

### Affected platform version

All

### Description

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

1. Clean VS/Sandbox
2. Install MAUI Dev Kit
3. Install Java and Android SDK following the directions
4. Run `dotnet build`
5. Observe the error
6. Run using F5
7. 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.

### Relevant log output

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.