bit setup --platforms android fails with MSB4044 on Linux with no Android SDK or JDK

未关闭
#14,757 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, csharp

调研方向

Start in ProjectSteps.cs at AndroidDependenciesAsync and compare its InstallAndroidDependencies arguments with the other call that builds android.csproj. Reproduce on Linux without a JDK or Android SDK, then check how the target receives AndroidSdkDirectory and JavaSdkDirectory. Done means setup installs the dependencies or reports what is missing, and the Android setup command succeeds in the reported environment.

由索引模型根据 Issue 内容生成。

描述

What happens

On a Linux machine that has neither a JDK nor an Android SDK, bit setup --platforms android stops at the Android step and exits with 1, although that step is the one meant to install them:

✗ Couldn't install the Android SDK and Java   MSB4044

The build it runs reports:

warning XA0034: Failed to get the Java SDK version. Please ensure you have Java 11.0 or above installed.
warning XA5300: The Android SDK directory could not be found.
error MSB4044: The "InstallAndroidDependencies" task was not given a value for the required parameter "AndroidSdkPath".

How to reproduce

  1. Use bit CLI 11.0.0-pre-17 on Ubuntu 24.04 with no JDK, no Android SDK, and neither JAVA_HOME nor ANDROID_HOME set. I used a ghcr.io/catthehacker/ubuntu:pwsh-24.04 container, running the project's CI locally with act.
  2. In a bit Boilerplate project that has the MAUI app, run bit setup --yes --platforms android --no-build --no-browsers.

Cause

ProjectSteps.AndroidDependenciesAsync runs:

dotnet build <Maui project> -t:InstallAndroidDependencies -f net10.0-android -p:AcceptAndroidSDKLicenses=True

Nothing tells InstallAndroidDependencies where to install. With no SDK to discover, AndroidSdkPath is empty and the task can't start. develop still builds the same arguments (checked at 99911c947).

GitHub's hosted runners hide this, since they come with a JDK and an Android SDK and set both variables.

With a JDK 17, the Android command-line tools and platform-tools already in the image, and JAVA_HOME and ANDROID_HOME set, the same command passes.

Suggested fix

When no SDK or JDK can be found, pass install locations to the target, for example -p:AndroidSdkDirectory=<dir> -p:JavaSdkDirectory=<dir> under the user's home folder. Otherwise, fail with a message saying what to install. The same applies to the other InstallAndroidDependencies call in ProjectSteps.cs, the one that builds android.csproj.

I only tested this on Linux. I don't know whether Windows or macOS without an SDK behave the same way.

主要语言
C#
星标
1.4k
派生
264
平均合并
7 小时 38 分钟
30 天内合并 PR
544

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bitfoundation/bitplatform 的其他 Issue

查看 bitfoundation/bitplatform 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。