Skip to content

Commit f93d3d8

Browse files
[One .NET] use API 31 "ref" pack with 32 "runtime" pack (#6647)
Commit 6eb11f1 added support for API-32, while keeping the .NET 6 default `$(TargetFramework)` value as `net6.0-android31.0`: > However, we don't want to change the default API level for .NET 6 > projects; the default will remain `net6.0-android31.0` (API-31), This appears to have had some unforeseen complications: we would use the API-31 `Mono.Android.dll`, with the API-32 `libmonodroid.so`/etc. runtime libraries. This in turn appears to be responsible for some crashes we've seen on CI ever since commit c227042 when running the `Mono.Android.NET_Tests` unit tests under .NET 6 with the interpreter enabled, because `libxamarin-app.so` and `libmonodroid.so` have ABI dependencies: DOTNET : JNI_OnLoad: JNI_OnLoad in pal_jni.c libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2 in tid 3666 (droid.NET_Tests), pid 3666 (droid.NET_Tests) crash_dump64: performing dump of process 3666 (target tid = 3666) DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** DEBUG : Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:10/QPP6.190730.005.B1/5775370:userdebug/test-keys' DEBUG : Revision: '0' DEBUG : ABI: 'x86_64' DEBUG : Timestamp: 2022-01-18 16:53:04+0000 DEBUG : pid: 3666, tid: 3666, name: droid.NET_Tests >>> Mono.Android.NET_Tests <<< DEBUG : uid: 10105 DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x2 DEBUG : Cause: null pointer dereference DEBUG : rax 0000000000002b36 rbx 000078c8afb3f860 rcx 000078c98b6561f0 rdx 0000000000000000 DEBUG : r8 0000000000000002 r9 0000000000000080 r10 000078c98b296080 r11 000078c987d35178 DEBUG : r12 00007fffe46ae99c r13 000078c8afb89ea0 r14 000078c8afb3f990 r15 000078c98b6746c0 DEBUG : rdi 000078c8afb3f860 rsi 0000000000000002 DEBUG : rbp 0000000000000001 rsp 00007fffe46ae448 rip 000078c8afb1b31c main : type=1400 audit(0.0:40): avc: granted { read } for name="u:object_r:net_dns_prop:s0" dev="tmpfs" ino=6642 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:net_dns_prop:s0 tclass=file app=Mono.Android.NET_Tests DEBUG : DEBUG : backtrace: DEBUG : #00 pc 000000000002c31c /data/app/Mono.Android.NET_Tests-fbdZV696v1UeW3jUzJg9yg==/lib/x86_64/libmonodroid.so (xamarin::android::Util::monodroid_store_package_name(char const*)+12) (BuildId: 91fe7d9c6b30356fcfb8337b8541d0132df4f44a) DEBUG : #1 pc 0000000000025bbc /data/app/Mono.Android.NET_Tests-fbdZV696v1UeW3jUzJg9yg==/lib/x86_64/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::Java_mono_android_Runtime_initInternal(_JNIEnv*, _jclass*, _jstring*, _jobjectArray*, _jstring*, _jobjectArray*, _jobject*, _jobjectArray*, int, unsigned char, unsigned char)+652) (BuildId: 91fe7d9c6b30356fcfb8337b8541d0132df4f44a) DEBUG : #2 pc 00000000000273fb /data/app/Mono.Android.NET_Tests-fbdZV696v1UeW3jUzJg9yg==/lib/x86_64/libmonodroid.so (Java_mono_android_Runtime_initInternal+75) (BuildId: 91fe7d9c6b30356fcfb8337b8541d0132df4f44a) DEBUG : #3 pc 0000000000174641 /apex/com.android.runtime/lib64/libart.so (art_quick_generic_jni_trampoline+209) (BuildId: 8bb3225e7c408f2ca23abac3db0417f2) … Thinking about it more, we should only need to use the API-31 "ref" or "targeting" pack. The "runtime" pack can just use the latest from the workload. To fix this: 1. Create new `$(_AndroidTargetingPackId)` and `$(_AndroidTargetingPackVersion)` properties to use independently of the runtime pack version. 2. Remove `Microsoft.Android.Runtime.31.[rid]` packs from the workload. 3. Remove the `android-32` workload, as it should no longer be needed. The API 31 "ref" pack is fairly small and can go in the `android` workload. Now our `android` workload is: * `Microsoft.Android.Sdk` * `Microsoft.Android.Ref.31` * `Microsoft.Android.Ref.32` * `Microsoft.Android.Runtime.32.android-arm` * `Microsoft.Android.Runtime.32.android-arm64` * `Microsoft.Android.Runtime.32.android-x86` * `Microsoft.Android.Runtime.32.android-x64` * `Microsoft.Android.Templates` After these changes, I get this assembly at build time: dotnet\packs\Microsoft.Android.Ref.31\31.0.101-preview.11.117\ref\net6.0\Mono.Android.dll And this assembly at runtime: dotnet\packs\Microsoft.Android.Runtime.32.android-arm64\31.0.200-preview.13.21\runtimes\android-arm64\lib\net6.0\Mono.Android.dll Additionally, CI is fully green; in particular, the **APKs .NET - macOS** step is green, which hasn't been true on xamarin-android/main since commit c227042.
1 parent a21d1a7 commit f93d3d8

File tree

3 files changed

+9
-36
lines changed

3 files changed

+9
-36
lines changed

build-tools/create-packs/Directory.Build.targets

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@
120120
<_NuGetSources Include="$(OutputPath.TrimEnd('\'))" />
121121
<_PreviewPacks Condition=" '$(AndroidLatestStableApiLevel)' != '$(AndroidLatestUnstableApiLevel)' " Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Ref.$(AndroidLatestUnstableApiLevel).*.nupkg" />
122122
<_InstallArguments Include="android-aot" />
123-
<!-- NOTE: temporary if $(AndroidDefaultTargetDotnetApiLevel) is not 32 -->
124-
<_InstallArguments Include="android-32" />
125123
<_InstallArguments Include="android-$(AndroidLatestUnstableApiLevel)" Condition=" '@(_PreviewPacks->Count())' != '0' " />
126124
<_InstallArguments Include="--skip-manifest-update" />
127125
<_InstallArguments Include="--verbosity diag" />

build-tools/create-packs/Microsoft.Android.Sdk.proj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
122122
<XamarinAndroidVersion>$(AndroidPackVersionLong)</XamarinAndroidVersion>
123123
</PropertyGroup>
124124
<PropertyGroup Condition=" '%24(TargetPlatformVersion)' == '31.0' ">
125-
<_AndroidRuntimePackId>31</_AndroidRuntimePackId>
126-
<_AndroidRuntimePackVersion>31.0.101-preview.11.117</_AndroidRuntimePackVersion>
125+
<_AndroidTargetingPackId>31</_AndroidTargetingPackId>
126+
<_AndroidTargetingPackVersion>31.0.101-preview.11.117</_AndroidTargetingPackVersion>
127127
</PropertyGroup>
128128
<PropertyGroup>
129+
<_AndroidTargetingPackId Condition=" '%24(_AndroidTargetingPackId)' == '' ">$(AndroidLatestStableApiLevel)</_AndroidTargetingPackId>
130+
<_AndroidTargetingPackVersion Condition=" '%24(_AndroidTargetingPackVersion)' == '' ">**FromWorkload**</_AndroidTargetingPackVersion>
129131
<_AndroidRuntimePackId Condition=" '%24(_AndroidRuntimePackId)' == '' ">$(AndroidLatestStableApiLevel)</_AndroidRuntimePackId>
130132
<_AndroidRuntimePackVersion Condition=" '%24(_AndroidRuntimePackVersion)' == '' ">**FromWorkload**</_AndroidRuntimePackVersion>
131133
</PropertyGroup>
@@ -135,8 +137,8 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
135137
TargetFramework="$(_AndroidNETAppTargetFramework)"
136138
RuntimeFrameworkName="Microsoft.Android"
137139
LatestRuntimeFrameworkVersion="%24(_AndroidRuntimePackVersion)"
138-
TargetingPackName="Microsoft.Android.Ref.%24(_AndroidRuntimePackId)"
139-
TargetingPackVersion="%24(_AndroidRuntimePackVersion)"
140+
TargetingPackName="Microsoft.Android.Ref.%24(_AndroidTargetingPackId)"
141+
TargetingPackVersion="%24(_AndroidTargetingPackVersion)"
140142
RuntimePackNamePatterns="Microsoft.Android.Runtime.%24(_AndroidRuntimePackId).**RID**"
141143
RuntimePackRuntimeIdentifiers="@(_AndroidNETAppRuntimePackRids, '%3B')"
142144
Profile="Android"

src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,15 @@
66
"packs": [
77
"Microsoft.Android.Sdk",
88
"Microsoft.Android.Ref.31",
9-
"Microsoft.Android.Runtime.31.android-arm",
10-
"Microsoft.Android.Runtime.31.android-arm64",
11-
"Microsoft.Android.Runtime.31.android-x86",
12-
"Microsoft.Android.Runtime.31.android-x64",
13-
"Microsoft.Android.Templates"
14-
],
15-
"platforms": [ "win-x64", "linux-x64", "osx-x64", "osx-arm64" ],
16-
"extends" : [ "microsoft-net-runtime-android" ]
17-
},
18-
"android-32": {
19-
"description": "Support for Android API-32.",
20-
"packs": [
219
"Microsoft.Android.Ref.32",
2210
"Microsoft.Android.Runtime.32.android-arm",
2311
"Microsoft.Android.Runtime.32.android-arm64",
2412
"Microsoft.Android.Runtime.32.android-x86",
25-
"Microsoft.Android.Runtime.32.android-x64"
13+
"Microsoft.Android.Runtime.32.android-x64",
14+
"Microsoft.Android.Templates"
2615
],
2716
"platforms": [ "win-x64", "linux-x64", "osx-x64", "osx-arm64" ],
28-
"extends" : [ "android" ]
17+
"extends" : [ "microsoft-net-runtime-android" ]
2918
},
3019
"android-aot": {
3120
"description": ".NET SDK Workload for building Android applications with AOT support.",
@@ -49,22 +38,6 @@
4938
"kind": "framework",
5039
"version": "31.0.101-preview.11.117"
5140
},
52-
"Microsoft.Android.Runtime.31.android-arm": {
53-
"kind": "framework",
54-
"version": "31.0.101-preview.11.117"
55-
},
56-
"Microsoft.Android.Runtime.31.android-arm64": {
57-
"kind": "framework",
58-
"version": "31.0.101-preview.11.117"
59-
},
60-
"Microsoft.Android.Runtime.31.android-x86": {
61-
"kind": "framework",
62-
"version": "31.0.101-preview.11.117"
63-
},
64-
"Microsoft.Android.Runtime.31.android-x64": {
65-
"kind": "framework",
66-
"version": "31.0.101-preview.11.117"
67-
},
6841
"Microsoft.Android.Ref.32": {
6942
"kind": "framework",
7043
"version": "@WORKLOAD_VERSION@"

0 commit comments

Comments
 (0)