Commit fd47b02
authored
[One .NET] support building net6.0-android apps in .NET 7 (#6988)
We currently have a hard dependency between:
* `Xamarin.Android.Build.Tasks.dll`
* `libmonodroid.so`
The design for building a `net6.0-android` app with a .NET 7 SDK
results in us using a .NET 7 `Xamarin.Android.Builds.Tasks.dll` and a
.NET 6 `libmonodroid.so`. This crashes with:
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed:
cannot locate symbol "java_name_width" referenced by
"/data/app/~~8CHtXY8wK4g7s9VcOLTQEg==/com.microsoft.net6.helloandroid-cUUhwuQls7TRb6JdBsbPdg==/split_config.arm64_v8a.apk!/lib/arm64-v8a/libmonodroid.so"...
To solve this problem:
* Define `$(AndroidNet6Version)` to specify our .NET 6 GA
`32.0.301` build that is released.
* Add an alias for a `Microsoft.Android.Sdk.$(HostOS).NET6`
workload pack that loads a .NET 6 version of
`Microsoft.Android.Sdk.$(HostOS)`.
* Include both the .NET 6 and .NET 7 versions of these packs in the
workload.
* Check `$(TargetFrameworkVersion)` and import the .NET 7 or .NET 6
MSBuild targets when appropriate.
* Update `@(KnownFrameworkReference)` to the version of .NET 6
that our .NET 7 packs know about.
* We have a matching .NET 6 `Xamarin.Android.Build.Tasks.dll` and
`libmonodroid.so`!
This obviously increases our install footprint of
`Microsoft.Android.Sdk.$(HostOS)` by 2x. We might be able to address
this by splitting out some files into a
`Microsoft.Android.Sdk.Tooling` pack that can be shared between
.NET 6 and .NET 7. (Perhaps files like `bundletool.jar` and `r8.jar`
could be shared?)
One hack I had to put in place was to avoid the crash:
E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed:
cannot locate symbol "mono_opt_aot_lazy_assembly_load" referenced by
"/data/app/~~Fp4gEr_9sxU1qU6PoI-v6Q==/com.companyname.foo-EKEtL67XJI-d0H17_3oz3g==/lib/arm64/libmonodroid.so"...
The .NET 7 SDK we are on does not yet know about .NET runtime 6.0.5
(it uses 6.0.3), so I manually fixed this version number for now.
We should be able to remove this eventually when the .NET 7 SDK
provides 6.0.5 by default.
A second hack I put in place:
Make `Microsoft.Android.Sdk.NET6` a "framework" and not an "sdk"
within `WorkloadManifest.json`. This prevents *both* the .NET 6
`AutoImport.props` *and* .NET 7 `AutoImport.props` files from being
imported, causing duplication of item groups/etc.
This seems very weird, but this still works:
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk" />
We can remove this if I condition everything in `AutoImport.props`
behind a current `$(TargetFrameworkVersion)`. We would then need to
ship this in a .NET 6 release.1 parent 90aec41 commit fd47b02
File tree
10 files changed
+85
-29
lines changed- build-tools/create-packs
- src/Xamarin.Android.Build.Tasks
- Microsoft.Android.Sdk/in
- Microsoft.NET.Sdk.Android
- Tests
- Xamarin.Android.Build.Tests
- Xamarin.ProjectTools/Common
- tests/MSBuildDeviceIntegration/Tests
10 files changed
+85
-29
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
41 | | - | |
42 | 47 | | |
| 48 | + | |
43 | 49 | | |
44 | 50 | | |
45 | 51 | | |
| |||
Lines changed: 0 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 21 | | |
34 | 22 | | |
35 | 23 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
43 | 55 | | |
44 | 56 | | |
45 | 57 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
241 | | - | |
| 240 | + | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
115 | 131 | | |
116 | 132 | | |
117 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
46 | 57 | | |
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
50 | 61 | | |
51 | | - | |
| 62 | + | |
52 | 63 | | |
53 | 64 | | |
54 | 65 | | |
| |||
62 | 73 | | |
63 | 74 | | |
64 | 75 | | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
140 | | - | |
| 152 | + | |
141 | 153 | | |
142 | 154 | | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| 158 | + | |
146 | 159 | | |
147 | 160 | | |
148 | 161 | | |
| |||
0 commit comments