dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

NETSDK1178 android workload missing #8760

Closed rene-descartes2021 closed 8 months ago

rene-descartes2021 commented 9 months ago

Android application type

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

Affected platform version

.NET 8.0.201

Description

android and maui-android workloads are not listed in dotnet workload search. At this time I'd like to use the android workload and I assume it's in this repository. First time attempting something like this so I could be doing something wrong.

/home/user/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1178: You may need to build the project on another operating system or architecture, or update the .NET SDK

In my readings I see android workload available on other's Linux OS with .NET 8, so I presume the arm64 host architecture is the issue. Or some other unknown. I can see it on my Linux OS desktop (x86_64) with .NET 7.

If not supported on Arm64 I'd appreciate any tips on the problem area to look, in order to possibly contribute.

Steps to Reproduce

Reproduction steps:

$ dotnet new install Microsoft.Android.Templates
$ dotnet new android
$ dotnet restore
/home/user/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1178: The project depends on the following workload packs that do not exist in any of the workloads available in this installation: Microsoft.Android.Sdk.net8 [/home/user/dev/android/android.csproj]
/home/user/.dotnet/sdk/8.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1178: You may need to build the project on another operating system or architecture, or update the .NET SDK. [/home/user/dev/android/android.csproj]

Restore failed with errors in 10.5s

Did you find any workaround?

No response

Relevant log output

$ dotnet workload update

Skipping NuGet package signature verification.
Skipping NuGet package signature verification.
Updated advertising manifest microsoft.net.workload.emscripten.current.
Updated advertising manifest microsoft.net.sdk.maui.
[...]
Updated advertising manifest microsoft.net.sdk.android.
[...]

$ dotnet workload search

Workload ID            Description
-------------------------------------------------------------------------
aspire                 .NET Aspire SDK (Preview)
macos                  .NET SDK Workload for building macOS applications.
maui-tizen             .NET MAUI SDK for Tizen
maui-windows           .NET MAUI SDK for Windows
wasi-experimental      workloads/wasi-experimental/description
wasm-experimental      workloads/wasm-experimental/description
wasm-tools             .NET WebAssembly build tools

$ dotnet workload install android
Workload ID android isn't supported on this platform.

$ dotnet workload restore
Installing workloads:

Skipping NuGet package signature verification.
Installing pack Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk version 8.0.2...
Pack Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk version 8.0.2 is already installed.
Writing workload pack installation record for Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk version 8.0.2...
Installing pack Microsoft.NETCore.App.Runtime.Mono.wasi-wasm version 8.0.2...
Pack Microsoft.NETCore.App.Runtime.Mono.wasi-wasm version 8.0.2 is already installed.
Writing workload pack installation record for Microsoft.NETCore.App.Runtime.Mono.wasi-wasm version 8.0.2...
Installing pack Microsoft.NET.Runtime.WebAssembly.Templates version 8.0.2...
Pack Microsoft.NET.Runtime.WebAssembly.Templates version 8.0.2 is already installed.
Writing workload pack installation record for Microsoft.NET.Runtime.WebAssembly.Templates version 8.0.2...
Installing pack Microsoft.NET.Runtime.MonoAOTCompiler.Task version 8.0.2...
Pack Microsoft.NET.Runtime.MonoAOTCompiler.Task version 8.0.2 is already installed.
Writing workload pack installation record for Microsoft.NET.Runtime.MonoAOTCompiler.Task version 8.0.2...
Installing pack Microsoft.NET.Runtime.MonoTargets.Sdk version 8.0.2...
Pack Microsoft.NET.Runtime.MonoTargets.Sdk version 8.0.2 is already installed.
Writing workload pack installation record for Microsoft.NET.Runtime.MonoTargets.Sdk version 8.0.2...
Garbage collecting for SDK feature band(s) 8.0.200...

Successfully installed workload(s) wasi-experimental.
$ dotnet --info
.NET SDK:
 Version:           8.0.201
 Commit:            4c2d78f037
 Workload version:  8.0.200-manifests.5638171e

Runtime Environment:
 OS Name:     debian
 OS Version:  12
 OS Platform: Linux
 RID:         linux-arm64
 Base Path:   /home/user/.dotnet/sdk/8.0.201/

.NET workloads installed:
 [wasi-experimental]
   Installation Source: SDK 8.0.200
   Manifest Version:    8.0.2/8.0.100
   Manifest Path:       /home/user/.dotnet/sdk-manifests/8.0.100/microsoft.net.workload.mono.toolchain.current/8.0.2/WorkloadManifest.json
   Install Type:        FileBased

Host:
  Version:      8.0.2
  Architecture: arm64
  Commit:       1381d5ebd2

.NET SDKs installed:
  8.0.201 [/home/user/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.2 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.2 [/home/user/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/user/.dotnet]

global.json file:
  Not found

How I installed dotnet SDK:

$ mv $HOME/.dotnet $HOME/.dotnet.bak
$ mkdir $HOME/.dotnet
$ tar zxf dotnet-sdk-8.0.201-linux-arm64.tar.gz -C $HOME/.dotnet
$ export DOTNET_ROOT=$HOME/.dotnet

Previously I tried 8.0.101 and that didn't work so I updated to 8.0.201 with same results.

jpobst commented 9 months ago

I think .NET Android will be supported on linux-arm64 in .NET 9, but isn't supported on .NET 8: https://github.com/xamarin/xamarin-android/pull/8500

You could try the .NET 9 preview and see if that works.

jonathanpeppers commented 9 months ago

Actually we have this change in the latest service release: https://github.com/xamarin/xamarin-android/releases/tag/34.0.79

Does dotnet workload install android --verbosity diag show the version of the android workload? 34.0.79 should have #8500 in it.

rene-descartes2021 commented 8 months ago

Oh wow, lucky me, I had no idea this was a new feature. I'm fine waiting a bit.

Does dotnet workload install android --verbosity diag show the version of the android workload? 34.0.79 should have #8500 in it.

--verbosity diag doesn't print anything additional in my case. No other parameter or environmental variable I tried changed anything. So I started searching the files/manifests.

I noticed indication of the prior version being in the filesystem, and looking at 34.0.43 files I see it doesn't have linux-arm64 while 34.0.79 does.

~/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.android$ ls
34.0.43  34.0.79

So I grep'd around for 34.0.43 and found this "baseline" manifest:

~/.dotnet/sdk-manifests/8.0.100/workloadsets/8.0.201-baseline.24114.5$ head baseline.workloadset.json
{
"Microsoft.NET.Sdk.Android": "34.0.43/8.0.100",
"Microsoft.NET.Sdk.iOS": "17.0.8478/8.0.100",
"Microsoft.NET.Sdk.MacCatalyst": "17.0.8478/8.0.100",
"Microsoft.NET.Sdk.macOS": "14.0.8478/8.0.100",
"Microsoft.NET.Sdk.Maui": "8.0.3/8.0.100",
"Microsoft.NET.Sdk.tvOS": "17.0.8478/8.0.100",
"Microsoft.NET.Workload.Mono.ToolChain.Current": "8.0.2/8.0.100",

So, maybe that is where the problem area is, that it's looking at the available architectures in the baseline version and not the most recent available?

Well, I'm fine waiting for the baseline to advance to 34.0.79, so I'll close this issue and will reopen if there is still problem then. Thank you!

jonathanpeppers commented 8 months ago

It seems like if you did dotnet workload update --verbosity diag, it should update the contents of this file:

dotnet/sdk-manifests/microsoft.net.sdk.android/8.0.100/WorkloadManifest.json

And this file should change to 34.0.79, or the latest version. Does it not?

rene-descartes2021 commented 8 months ago
dotnet/sdk-manifests/microsoft.net.sdk.android/8.0.100/WorkloadManifest.json

And this file should change to 34.0.79, or the latest version. Does it not?

I don't see that particular path, it's different on my system:

$ ls -l ~/.dotnet/sdk-manifests/
total 4
drwxr-xr-x. 16 user users 3452 Feb 14 18:25 8.0.100

Here are a few similar paths I see.

WorkloadManifest.json under sdk-advertising:

$ head -n 20 ~/.dotnet/sdk-advertising/8.0.200/microsoft.net.sdk.android/WorkloadManifest.json
{
  "version": "34.0.79",
  "workloads": {
    "android": {
      "description": ".NET SDK Workload for building Android applications.",
      "packs": [
        "Microsoft.Android.Sdk.net8",
        "Microsoft.Android.Sdk.net7",
        "Microsoft.Android.Ref.34",
        "Microsoft.Android.Runtime.34.android-arm",
        "Microsoft.Android.Runtime.34.android-arm64",
        "Microsoft.Android.Runtime.34.android-x86",
        "Microsoft.Android.Runtime.34.android-x64",
        "Microsoft.Android.Templates"
      ],
      "platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ],
      "extends" : [
        "microsoft-net-runtime-android-net7",
        "microsoft-net-runtime-android-aot-net7",
        "microsoft-net-runtime-android",

Two versions of WorkloadManifest.json under sdk-manifests, the latter with linux-arm64:

~$ head -n 20 ~/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.android/34.0.43/WorkloadManifest.json
{
  "version": "34.0.43",
  "workloads": {
    "android": {
      "description": ".NET SDK Workload for building Android applications.",
      "packs": [
        "Microsoft.Android.Sdk.net8",
        "Microsoft.Android.Sdk.net7",
        "Microsoft.Android.Ref.34",
        "Microsoft.Android.Runtime.34.android-arm",
        "Microsoft.Android.Runtime.34.android-arm64",
        "Microsoft.Android.Runtime.34.android-x86",
        "Microsoft.Android.Runtime.34.android-x64",
        "Microsoft.Android.Templates"
      ],
      "platforms": [ "win-x64", "win-arm64", "linux-x64", "osx-x64", "osx-arm64" ],
      "extends" : [
        "microsoft-net-runtime-android-net7",
        "microsoft-net-runtime-android-aot-net7",
        "microsoft-net-runtime-android",
$ head -n 20 ~/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.android/34.0.79/WorkloadManifest.json
{
  "version": "34.0.79",
  "workloads": {
    "android": {
      "description": ".NET SDK Workload for building Android applications.",
      "packs": [
        "Microsoft.Android.Sdk.net8",
        "Microsoft.Android.Sdk.net7",
        "Microsoft.Android.Ref.34",
        "Microsoft.Android.Runtime.34.android-arm",
        "Microsoft.Android.Runtime.34.android-arm64",
        "Microsoft.Android.Runtime.34.android-x86",
        "Microsoft.Android.Runtime.34.android-x64",
        "Microsoft.Android.Templates"
      ],
      "platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ],
      "extends" : [
        "microsoft-net-runtime-android-net7",
        "microsoft-net-runtime-android-aot-net7",
        "microsoft-net-runtime-android",