8
8
using System . Reflection . PortableExecutable ;
9
9
using System . Text ;
10
10
using Microsoft . Build . Framework ;
11
+ using Microsoft . Build . Utilities ;
11
12
12
13
using Java . Interop . Tools . TypeNameMappings ;
13
14
using Xamarin . Android . Tools ;
@@ -237,6 +238,10 @@ public override bool RunTask ()
237
238
}
238
239
239
240
var uniqueNativeLibraries = new List < ITaskItem > ( ) ;
241
+
242
+ // Number of DSOs that will be packaged, it may be different to the number of items in the above
243
+ // `uniqueNativeLibraries` list.
244
+ uint packagedNativeLibrariesCount = 0 ;
240
245
var seenNativeLibraryNames = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) ;
241
246
if ( NativeLibraries != null ) {
242
247
foreach ( ITaskItem item in NativeLibraries ) {
@@ -246,9 +251,19 @@ public override bool RunTask ()
246
251
continue ;
247
252
}
248
253
254
+ if ( ! ELFHelper . IsEmptyAOTLibrary ( Log , item . ItemSpec ) ) {
255
+ packagedNativeLibrariesCount ++ ;
256
+ }
257
+
249
258
seenNativeLibraryNames . Add ( name ) ;
250
259
uniqueNativeLibraries . Add ( item ) ;
251
260
}
261
+
262
+ // libxamarin-app.so is not in NativeLibraries, but we must count it
263
+ if ( ! seenNativeLibraryNames . Contains ( "libxamarin-app.so" ) ) {
264
+ uniqueNativeLibraries . Add ( new TaskItem ( "libxamarin-app.so" ) ) ;
265
+ packagedNativeLibrariesCount ++ ;
266
+ }
252
267
}
253
268
254
269
var jniRemappingNativeCodeInfo = BuildEngine4 . GetRegisteredTaskObjectAssemblyLocal < GenerateJniRemappingNativeCode . JniRemappingNativeCodeInfo > ( ProjectSpecificTaskObjectKey ( GenerateJniRemappingNativeCode . JniRemappingNativeCodeInfoKey ) , RegisteredTaskObjectLifetime . Build ) ;
@@ -264,6 +279,7 @@ public override bool RunTask ()
264
279
NumberOfAssembliesInApk = assemblyCount ,
265
280
BundledAssemblyNameWidth = assemblyNameWidth ,
266
281
NativeLibraries = uniqueNativeLibraries ,
282
+ PackagedNativeLibrariesCount = packagedNativeLibrariesCount ,
267
283
AndroidRuntimeJNIEnvToken = android_runtime_jnienv_class_token ,
268
284
JNIEnvInitializeToken = jnienv_initialize_method_token ,
269
285
JNIEnvRegisterJniNativesToken = jnienv_registerjninatives_method_token ,
@@ -301,6 +317,7 @@ public override bool RunTask ()
301
317
BundledAssemblyNameWidth = assemblyNameWidth ,
302
318
MonoComponents = ( MonoComponent ) monoComponents ,
303
319
NativeLibraries = uniqueNativeLibraries ,
320
+ PackagedNativeLibrariesCount = packagedNativeLibrariesCount ,
304
321
HaveAssemblyStore = UseAssemblyStore ,
305
322
AndroidRuntimeJNIEnvToken = android_runtime_jnienv_class_token ,
306
323
JNIEnvInitializeToken = jnienv_initialize_method_token ,
0 commit comments