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

Đang mở
#14,757 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, csharp
Lĩnh vực
build-system, mobile

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
1.4k
Fork
264
Merge trung bình
7 giờ 38 phút
Pull request đã merge (30 ngày)
544

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bitfoundation/bitplatform

Tất cả issue của bitfoundation/bitplatform

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.