1
- # .NET 6 - Xamarin.Android Binding Migration
1
+ # .NET 6+ - Xamarin.Android Binding Migration
2
2
3
3
## Consolidation of binding projects
4
4
5
- In .NET 6, there is no longer a concept of a [ binding
5
+ In .NET 6+ , there is no longer a concept of a [ binding
6
6
project] [ binding ] as a separate project type. Any of the MSBuild item
7
7
groups or build actions that currently work in binding projects will
8
- be supported through a .NET 6 Android application or library.
8
+ be supported through a .NET 6+ Android application or library.
9
9
10
10
For example, a binding library would be identical to a class library:
11
11
@@ -26,7 +26,7 @@ libraries, just that the project file will look the same as an application.
26
26
27
27
The following legacy options are no longer supported. The supported alternatives
28
28
have been available for several years, and the smoothest migration option is to update
29
- and test your current projects with these options ** first** before migrating them to .NET 6.
29
+ and test your current projects with these options ** first** before migrating them to .NET 6+ .
30
30
31
31
### ` <AndroidClassParser> `
32
32
@@ -91,6 +91,44 @@ Or exclude *all* files within that folder:
91
91
92
92
[ default-items ] : https://github.com/xamarin/xamarin-android/blob/main/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/Sdk/AutoImport.props
93
93
94
+ ## Embedded ` .jar ` ./` .aar `
95
+
96
+ In Xamarin.Android Classic, the Java ` .jar ` or ` .aar ` was often embedded into the binding ` .dll `
97
+ as an Embedded Resource.
98
+
99
+ However, this led to slow builds, as each ` .dll ` must be opened and scanned for Java code. If
100
+ found, it must be extracted to disk to be used.
101
+
102
+ In .NET 6+, Java code is no longer embedded in the ` .dll ` . The application build process will
103
+ automatically include any ` .jar ` or ` .aar ` files it finds in the same directory as a referenced ` .dll ` .
104
+
105
+ If a project references a binding via ` <PackageReference> ` or ` <ProjectReference> ` then everything
106
+ just works and no additional considerations are needed.
107
+
108
+ However if a project references a binding via ` <Reference> ` , the ` .jar ` /` .aar ` must be located next
109
+ to the ` .dll ` .
110
+
111
+ That is, for a reference like this:
112
+
113
+ ``` xml
114
+ <Reference Include =" MyBinding.dll" />
115
+ ```
116
+
117
+ A directory like this will not work:
118
+
119
+ ```
120
+ \lib
121
+ - MyBinding.dll
122
+ ```
123
+
124
+ The directory must contain the native code as well:
125
+
126
+ ```
127
+ \lib
128
+ - MyBinding.dll
129
+ - mybinding.jar
130
+ ```
131
+
94
132
## Migration Considerations
95
133
96
134
There are several new features set by default to help produce new bindings that better match their
@@ -173,7 +211,7 @@ Setting it to `true` will result in "un-nesting" any nested types (legacy behavi
173
211
<attr path =" /api/package[@name='my.package']/interface[@name='Foo']" name =" unnest" >true</attr >
174
212
```
175
213
176
- Setting it to ` false ` will result in nested types remaining nested in the ` interface ` (.NET 6 behavior):
214
+ Setting it to ` false ` will result in nested types remaining nested in the ` interface ` (.NET 6+ behavior):
177
215
178
216
``` xml
179
217
<attr path =" /api/package[@name='my.package']/interface[@name='Foo']" name =" unnest" >false</attr >
@@ -234,7 +272,7 @@ This continues to be enabled/disabled using the same mechanism as all .NET proje
234
272
</PropertyGroup >
235
273
```
236
274
237
- As the default for .NET 6 is ` disable ` , the same applies for Xamarin Android projects.
275
+ As the default for .NET 6+ is ` disable ` , the same applies for Xamarin Android projects.
238
276
239
277
Use ` enable ` as shown above to enable NRT support.
240
278
@@ -243,7 +281,7 @@ Use `enable` as shown above to enable NRT support.
243
281
### ` Resource.designer.cs `
244
282
245
283
In Xamarin.Android, Java binding projects did not support generating a ` Resource.designer.cs ` file.
246
- Since binding projects are just class libraries in .NET 6, this file will be generated. This could
284
+ Since binding projects are just class libraries in .NET 6+ , this file will be generated. This could
247
285
be a breaking change when migrating existing projects.
248
286
249
287
One example of a failure from this change, is if your binding generates a class named ` Resource `
0 commit comments