Skip to content

MAUI Extension doesn't respect JAVA_HOME or ANDROID_HOME #2372

@sbomer

Description

@sbomer

I followed the recommended installation steps to install the JDK and Android SDK, and ensured JAVA_HOME and ANDROID_HOME were set in VS Code.

From https://learn.microsoft.com/dotnet/maui/get-started/installation?view=net-maui-9.0&tabs=visual-studio-code#download-and-install-the-java-sdk:

  1. Ensure that you've configured the path to OpenJDK via one of the following approaches:
    a. Set the JAVA_HOME environment variable to define the Java SDK path for your machine. This is the recommended approach, which defines the Java SDK path at the machine level.

From https://learn.microsoft.com/dotnet/maui/get-started/installation?view=net-maui-9.0&tabs=visual-studio-code#download-and-install-the-android-sdk:

  1. Ensure that you've configured the path to the Android SDK via one of the following approaches:
    a. Set the ANDROID_HOME environment variable to define the Android SDK path for your machine. This is the recommended approach, which defines the Android SDK path at the machine level.

VS code has these env vars set:

~/src/maui-app$ echo $ANDROID_HOME
/home/svbomer/android-sdk
~/src/maui-app$ echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-amd64

I ensured that my VS Code settings do not set the variables for the java sdk or android sdk.

However, "refresh android environment" picks the wrong java environment:

	✓ Java SDK - INSTALLED (version '21.0.8')
		- Path: '/home/svbomer/android-toolchain/jdk-21' (Workload)
		- Recommended detected locations:
			- '/usr/lib/jvm/java-17-openjdk-amd64' (JAVA_HOME)
			- '/usr'

Note that it detects JAVA_HOME, but doesn't select that one. I would expect following the recommended path to just work. I have seen similar issues with ANDROID_SDK as well.

I'm using version 1.11.14 of the .NET MAUI extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions