Skip to content

Rethink .NET Workload Pack Structure #7183

Description

@jonpryor

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6.0.400 / 32.0.440

Description

Context? 0ab3db0

Today, when we build a .NET 6 app, we build the app against the latest runtime pack, no matter what $(TargetFramework) was specified. If $(TargetFramework)=net6.0-android (API-31), then the app assembly is built against the API-31 reference pack, but the App is packaged using the API-33 assemblies.

The result is that in some circumstances, API-33 members may be used by Java Callable Wrappers, even if API-33 isn't installed; even if API-33 android.jar is installed, it won't be used by JCW compilation.


The original reason for using the latest runtime pack during app build (TODO: commit?) is because libmonodroid.so (via libmono-android.debug.so, libmono-android.release.so, and libxamarin-debug-app-helper.so) is "tied at the hip" to Xamarin.Android.Build.Tasks.dll (XABT), as XABT emits LLVM-IR/assembly/etc. which depends upon internals of libmonodroid.so. As the runtime pack contains the libmonodroid.so files, it thus felt appropriate to always use the latest runtime pack, as that was the version that would match the SDK pack (which contains XABT).

We are now hitting an unexpected corner case of this arrangement.

What we should instead do is place related components into the same pack. As libmonodroid.so & XABT are tied to each other, libmonodroid.so should instead be distributed in the SDK packs, not the runtime packs.

Steps to Reproduce

Create a new Android app:

dotnet new android -n implicit_api33

Edit MainActivity.cs to add:

sealed class MyThread : global::Java.Lang.Thread
{
}

Build the app.

Expected results: it builds! (It does build with .NET 6.0.300…)

Actual results (with .NET 6.0.400): it doesn't build; Java Callable Wrapper compilation fails:

JAVAC0000 error: no suitable constructor found for Thread(ThreadGroup,Runnable,String,long.boolean)

Did you find any workaround?

Build the app against API-33, by setting $(TargetFramework)=net6.0-android33.0.

Relevant log output

No response

Metadata

Metadata

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions