-
Notifications
You must be signed in to change notification settings - Fork 534
/
Copy pathBuildTest.cs
4324 lines (4064 loc) · 194 KB
/
BuildTest.cs
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Microsoft.Build.Framework;
using Mono.Cecil;
using NUnit.Framework;
using Xamarin.Android.Tasks;
using Xamarin.Android.Tools;
using Xamarin.ProjectTools;
namespace Xamarin.Android.Build.Tests
{
[Category ("Node-1")]
[Parallelizable (ParallelScope.Children)]
public partial class BuildTest : BaseTest
{
[Test]
public void CompressedWithoutLinker ()
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = true
};
proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidLinkMode, AndroidLinkMode.None.ToString ());
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[Category ("dotnet")]
public void BuildBasicApplication ([Values (true, false)] bool isRelease)
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease,
};
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[Category ("SmokeTests")]
public void BuildBasicApplicationReleaseProfiledAot ()
{
var proj = new XamarinAndroidApplicationProject () {
IsRelease = true,
AndroidEnableProfiledAot = true,
};
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidExtraAotOptions", "--verbose");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
StringAssertEx.ContainsRegex (@"\[aot-compiler stdout\] Using profile data file.*build.Xamarin.Android.startup\.aotprofile", b.LastBuildOutput, "Should use default AOT profile", RegexOptions.IgnoreCase);
StringAssertEx.ContainsRegex (@"\[aot-compiler stdout\] Method.*emitted at", b.LastBuildOutput, "Should contain verbose AOT compiler output", RegexOptions.IgnoreCase);
}
}
[Test]
public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile ()
{
var proj = new XamarinAndroidApplicationProject () {
IsRelease = true,
AndroidEnableProfiledAot = true,
};
proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseDefaultAotProfile", "false");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
StringAssertEx.DoesNotContainRegex (@"\[aot-compiler stdout\] Using profile data file.*build.Xamarin.Android.startup.*\.aotprofile", b.LastBuildOutput, "Should not use default AOT profile", RegexOptions.IgnoreCase);
}
}
static readonly object [] BuildHasNoWarningsSource = new object [] {
new object [] {
/* isRelease */ false,
/* xamarinForms */ false,
/* multidex */ false,
/* packageFormat */ "apk",
},
new object [] {
/* isRelease */ false,
/* xamarinForms */ true,
/* multidex */ false,
/* packageFormat */ "apk",
},
new object [] {
/* isRelease */ false,
/* xamarinForms */ true,
/* multidex */ true,
/* packageFormat */ "apk",
},
new object [] {
/* isRelease */ true,
/* xamarinForms */ false,
/* multidex */ false,
/* packageFormat */ "apk",
},
new object [] {
/* isRelease */ true,
/* xamarinForms */ true,
/* multidex */ false,
/* packageFormat */ "apk",
},
new object [] {
/* isRelease */ false,
/* xamarinForms */ false,
/* multidex */ false,
/* packageFormat */ "aab",
},
new object [] {
/* isRelease */ true,
/* xamarinForms */ false,
/* multidex */ false,
/* packageFormat */ "aab",
},
};
[Test]
[Category ("dotnet")]
[TestCaseSource (nameof (BuildHasNoWarningsSource))]
public void BuildHasNoWarnings (bool isRelease, bool xamarinForms, bool multidex, string packageFormat)
{
var proj = xamarinForms ?
new XamarinFormsAndroidApplicationProject () :
new XamarinAndroidApplicationProject ();
if (multidex) {
proj.SetProperty ("AndroidEnableMultiDex", "True");
}
if (packageFormat == "aab") {
// Disable fast deployment for aabs, because we give:
// XA0119: Using Fast Deployment and Android App Bundles at the same time is not recommended.
proj.EmbedAssembliesIntoApk = true;
proj.AndroidUseSharedRuntime = false;
}
proj.SetProperty ("XamarinAndroidSupportSkipVerifyVersions", "True"); // Disables API 29 warning in Xamarin.Build.Download
proj.SetProperty ("AndroidPackageFormat", packageFormat);
if (proj.IsRelease = isRelease && !Builder.UseDotNet) {
proj.SetProperty ("MonoSymbolArchive", "True");
}
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), "Should have no MSBuild warnings.");
Assert.IsFalse (StringAssertEx.ContainsText (b.LastBuildOutput, "Warning: end of file not at end of a line"),
"Should not get a warning from the <CompileNativeAssembly/> task.");
var lockFile = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, ".__lock");
FileAssert.DoesNotExist (lockFile);
}
}
[Test]
public void BuildBasicApplicationWithNuGetPackageConflicts ()
{
var proj = new XamarinAndroidApplicationProject () {
PackageReferences = {
new Package () {
Id = "System.Buffers",
Version = "4.4.0",
TargetFramework = "monoandroid90",
},
new Package () {
Id = "System.Memory",
Version = "4.5.1",
TargetFramework = "monoandroid90",
},
}
};
proj.Sources.Add (new BuildItem ("Compile", "IsAndroidDefined.fs") {
TextContent = () => @"
using System;
class MemTest {
static void Test ()
{
var x = new Memory<int> ().Length;
Console.WriteLine (x);
var array = new byte [100];
var arraySpan = new Span<byte> (array);
Console.WriteLine (arraySpan.IsEmpty);
}
}"
});
using (var b = CreateApkBuilder ("temp/BuildBasicApplicationWithNuGetPackageConflicts")) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[Category ("Minor")]
[NonParallelizable] // parallel NuGet restore causes failures
public void BuildBasicApplicationFSharp ([Values (true, false)] bool isRelease)
{
var proj = new XamarinAndroidApplicationProject {
Language = XamarinAndroidProjectLanguage.FSharp,
IsRelease = isRelease,
};
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[NonParallelizable]
public void BuildBasicApplicationAppCompat ([Values (true, false)] bool usePackageReference)
{
var proj = new XamarinAndroidApplicationProject ();
var packages = usePackageReference ? proj.PackageReferences : proj.Packages;
packages.Add (KnownPackages.SupportV7AppCompat_27_0_2_1);
// packages.config needs every dependency listed
if (!usePackageReference) {
packages.Add (KnownPackages.Android_Arch_Core_Common_26_1_0);
packages.Add (KnownPackages.Android_Arch_Lifecycle_Common_26_1_0);
packages.Add (KnownPackages.Android_Arch_Lifecycle_Runtime_26_1_0);
packages.Add (KnownPackages.SupportFragment_27_0_2_1);
packages.Add (KnownPackages.SupportCompat_27_0_2_1);
packages.Add (KnownPackages.SupportCoreUI_27_0_2_1);
packages.Add (KnownPackages.SupportCoreUtils_27_0_2_1);
}
proj.MainActivity = proj.DefaultMainActivity.Replace ("public class MainActivity : Activity", "public class MainActivity : Android.Support.V7.App.AppCompatActivity");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[Category ("dotnet")]
[NonParallelizable]
public void AndroidXMigration ([Values (true, false)] bool isRelease)
{
var proj = new XamarinFormsAndroidApplicationProject {
IsRelease = isRelease,
};
proj.PackageReferences.Add (KnownPackages.AndroidXMigration);
proj.PackageReferences.Add (KnownPackages.AndroidXAppCompat);
proj.PackageReferences.Add (KnownPackages.AndroidXAppCompatResources);
proj.PackageReferences.Add (KnownPackages.AndroidXBrowser);
proj.PackageReferences.Add (KnownPackages.AndroidXMediaRouter);
proj.PackageReferences.Add (KnownPackages.AndroidXLegacySupportV4);
proj.PackageReferences.Add (KnownPackages.AndroidXLifecycleLiveData);
proj.PackageReferences.Add (KnownPackages.XamarinGoogleAndroidMaterial);
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
var dexFile = b.Output.GetIntermediaryPath (Path.Combine ("android", "bin", "classes.dex"));
FileAssert.Exists (dexFile);
// classes.dex should only have the androidx Java types
var className = "Landroidx/appcompat/app/AppCompatActivity;";
Assert.IsTrue (DexUtils.ContainsClass (className, dexFile, AndroidSdkPath), $"`{dexFile}` should include `{className}`!");
className = "Landroid/appcompat/app/AppCompatActivity;";
Assert.IsFalse (DexUtils.ContainsClass (className, dexFile, AndroidSdkPath), $"`{dexFile}` should *not* include `{className}`!");
// FormsAppCompatActivity should inherit the AndroidX C# type
var forms = Builder.UseDotNet && isRelease ?
b.Output.GetIntermediaryPath (Path.Combine ("linked", "Xamarin.Forms.Platform.Android.dll")) :
b.Output.GetIntermediaryPath (Path.Combine ("android", "assets", "Xamarin.Forms.Platform.Android.dll"));
using (var assembly = AssemblyDefinition.ReadAssembly (forms)) {
var activity = assembly.MainModule.GetType ("Xamarin.Forms.Platform.Android.FormsAppCompatActivity");
Assert.AreEqual ("AndroidX.AppCompat.App.AppCompatActivity", activity.BaseType.FullName);
}
}
}
[Test]
public void DuplicateReferences ()
{
var proj = new XamarinAndroidApplicationProject ();
proj.MainActivity = proj.DefaultMainActivity.Replace ("public class MainActivity : Activity", "public class MainActivity : Android.Support.V7.App.AppCompatActivity");
var package = KnownPackages.SupportV7AppCompat_27_0_2_1;
var fullPath = Path.GetFullPath (Path.Combine (Root, "temp", "packages", $"{package.Id}.{package.Version}", "lib", package.TargetFramework, $"{package.Id}.dll"));
proj.PackageReferences.Add (package);
proj.Packages.Add (package);
proj.References.Add (new BuildItem.Reference (package.Id) {
MetadataValues = "HintPath=" + fullPath,
});
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "first build should have succeeded.");
// Remove NuGet packages, but leave References
proj.PackageReferences.Clear ();
proj.Packages.Clear ();
Assert.IsTrue (b.Build (proj), "second build should have succeeded.");
}
}
[Test]
public void DuplicateRJavaOutput ()
{
var proj = new XamarinAndroidApplicationProject {
PackageReferences = {
new Package { Id = "Xamarin.Android.Support.Annotations", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.Compat", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.Core.UI", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.Core.Utils", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.Design", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.Fragment", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.VersionedParcelable", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Android.Support.v4", Version = "28.0.0.3" },
new Package { Id = "Xamarin.Build.Download", Version = "0.7.1" },
new Package { Id = "Xamarin.Essentials", Version = "1.3.1" },
new Package { Id = "Xamarin.GooglePlayServices.Ads.Identifier", Version = "71.1600.0" },
new Package { Id = "Xamarin.GooglePlayServices.Base", Version = "71.1610.0" },
new Package { Id = "Xamarin.GooglePlayServices.Basement", Version = "71.1620.0" },
new Package { Id = "Xamarin.GooglePlayServices.Clearcut", Version = "71.1600.0" },
new Package { Id = "Xamarin.GooglePlayServices.Measurement.Api", Version = "71.1630.0" },
new Package { Id = "Xamarin.GooglePlayServices.Measurement.Base", Version = "71.1630.0" },
new Package { Id = "Xamarin.GooglePlayServices.Phenotype", Version = "71.1600.0" },
new Package { Id = "Xamarin.GooglePlayServices.Stats", Version = "71.1601.0" },
new Package { Id = "Xamarin.GooglePlayServices.Tasks", Version = "71.1601.0" },
}
};
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
var lines = b.LastBuildOutput.Where (l => l.Contains ("Writing:") && l.Contains ("R.java"));
var hash = new HashSet<string> (StringComparer.Ordinal);
foreach (var duplicate in lines.Where (i => !hash.Add (i))) {
Assert.Fail ($"Duplicate: {duplicate}");
}
}
}
[Test]
[Category ("SmokeTests")]
[NonParallelizable] // parallel NuGet restore causes failures
public void BuildXamarinFormsMapsApplication ([Values (true, false)] bool multidex)
{
var proj = new XamarinFormsMapsApplicationProject ();
if (multidex)
proj.SetProperty ("AndroidEnableMultiDex", "True");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "first should have succeeded.");
b.BuildLogFile = "build2.log";
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "second should have succeeded.");
var targets = new [] {
"_CompileResources",
"_UpdateAndroidResgen",
};
foreach (var target in targets) {
Assert.IsTrue (b.Output.IsTargetSkipped (target), $"`{target}` should be skipped.");
}
proj.Touch ("MainPage.xaml");
b.BuildLogFile = "build3.log";
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "third should have succeeded.");
foreach (var target in targets) {
Assert.IsTrue (b.Output.IsTargetSkipped (target), $"`{target}` should be skipped.");
}
Assert.IsFalse (b.Output.IsTargetSkipped ("CoreCompile"), $"`CoreCompile` should not be skipped.");
b.BuildLogFile = "build4.log";
Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true, saveProject: false), "forth should have succeeded.");
foreach (var target in targets) {
Assert.IsTrue (b.Output.IsTargetSkipped (target), $"`{target}` should be skipped.");
}
}
}
[Test]
public void CodeAnalysis ()
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = true
};
proj.SetProperty ("RunCodeAnalysis", "True");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
b.Target = "Build";
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[NonParallelizable]
public void SkipConvertResourcesCases ([Values (false, true)] bool useAapt2)
{
var target = "ConvertResourcesCases";
var proj = new XamarinFormsAndroidApplicationProject ();
proj.SetProperty ("AndroidUseAapt2", useAapt2.ToString ());
proj.OtherBuildItems.Add (new BuildItem ("AndroidAarLibrary", "Jars\\material-menu-1.1.0.aar") {
WebContent = "https://repo.jfrog.org/artifactory/libs-release-bintray/com/balysv/material-menu/1.1.0/material-menu-1.1.0.aar"
});
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should not be skipped.");
List<string> skipped = new List<string> (), processed = new List<string> ();
bool convertResourcesCases = false;
foreach (var line in b.LastBuildOutput) {
if (!convertResourcesCases) {
convertResourcesCases = line.StartsWith ($"Task \"{target}\"", StringComparison.OrdinalIgnoreCase);
} else if (line.StartsWith ($"Done executing task \"{target}\"", StringComparison.OrdinalIgnoreCase)) {
convertResourcesCases = false; //end of target
}
if (convertResourcesCases) {
if (line.IndexOf ("Processing:", StringComparison.OrdinalIgnoreCase) >= 0) {
//Processing: obj\Debug\res\layout\main.xml 10/29/2018 8:19:36 PM > 1/1/0001 12:00:00 AM
processed.Add (line);
} else if (line.IndexOf ("Skipping:", StringComparison.OrdinalIgnoreCase) >= 0) {
//Skipping: `obj\Debug\lp\5\jl\res` via `AndroidSkipResourceProcessing`, original file: `bin\TestDebug\temp\packages\Xamarin.Android.Support.Compat.27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll`...
skipped.Add (line);
}
}
}
var resources = new [] {
Path.Combine ("layout", "main.xml"),
Path.Combine ("layout", "tabbar.xml"),
Path.Combine ("layout", "toolbar.xml"),
Path.Combine ("values", "colors.xml"),
Path.Combine ("values", "strings.xml"),
Path.Combine ("values", "styles.xml"),
};
foreach (var resource in resources) {
Assert.IsTrue (processed.ContainsText (resource), $"`{target}` should process `{resource}`.");
}
var files = new [] {
"Xamarin.Android.Support.Compat.dll",
"Xamarin.Android.Support.Design.dll",
"Xamarin.Android.Support.Media.Compat.dll",
"Xamarin.Android.Support.Transition.dll",
"Xamarin.Android.Support.v7.AppCompat.dll",
"Xamarin.Android.Support.v7.CardView.dll",
"Xamarin.Android.Support.v7.MediaRouter.dll",
"Xamarin.Android.Support.v7.RecyclerView.dll",
"material-menu-1.1.0.aar",
};
foreach (var file in files) {
Assert.IsTrue (StringAssertEx.ContainsText (skipped, file), $"`{target}` should skip `{file}`.");
}
}
}
[Test]
public void BuildInParallel ()
{
if (!IsWindows) {
//TODO: one day we should fix the problems here, various MSBuild tasks step on each other when built in parallel
Assert.Ignore ("Currently ignoring this test on non-Windows platforms.");
}
var proj = new XamarinFormsAndroidApplicationProject ();
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
//We don't want these things stepping on each other
b.BuildLogFile = null;
b.Save (proj, saveProject: true);
proj.NuGetRestore (Path.Combine (Root, b.ProjectDirectory), b.PackagesDirectory);
Parallel.For (0, 5, i => {
try {
//NOTE: things are going to break here
b.Build (proj);
} catch (Exception exc) {
TestContext.WriteLine ("Expected error in {0}: {1}", nameof (BuildInParallel), exc);
}
});
//The key here, is a build afterward should work
b.BuildLogFile = "after.log";
Assert.IsTrue (b.Build (proj), "The build after a parallel failed build should succeed!");
}
}
[Test]
public void CheckKeystoreIsCreated ()
{
var proj = new XamarinAndroidApplicationProject () {
IsRelease = true,
};
using (var b = CreateApkBuilder ("temp/CheckKeystoreIsCreated", false, false)) {
var file = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "debug.keystore");
var p = new string [] {
$"_ApkDebugKeyStore={file}",
};
Assert.IsTrue (b.Build (proj, parameters: p), "Build should have succeeded.");
FileAssert.Exists (file, $"{file} should have been created.");
}
}
[Test]
[NonParallelizable] // parallel NuGet restore causes failures
public void FSharpAppHasAndroidDefine ()
{
var proj = new XamarinAndroidApplicationProject () {
Language = XamarinAndroidProjectLanguage.FSharp,
};
proj.Sources.Add (new BuildItem ("Compile", "IsAndroidDefined.fs") {
TextContent = () => @"
module Xamarin.Android.Tests
// conditional compilation; can we elicit a compile-time error?
let x =
#if __ANDROID__
42
#endif // __ANDROID__
printf ""%d"" x
",
});
using (var b = CreateApkBuilder ("temp/" + nameof (FSharpAppHasAndroidDefine))) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
public void DesignTimeBuildHasAndrodDefine ()
{
var proj = new XamarinAndroidApplicationProject () {
};
proj.Sources.Add (new BuildItem ("Compile", "IsAndroidDefined.cs") {
TextContent = () => @"
namespace Xamarin.Android.Tests
{
public class Foo {
public void FooMethod () {
#if !__ANDROID__ || !__MOBILE__
Compile Error please :)
#endif
}
}
}
",
});
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName ))) {
b.Target = "Compile";
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
public void SwitchBetweenDesignTimeBuild ()
{
var proj = new XamarinAndroidApplicationProject ();
proj.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\layout\\custom_text.xml") {
TextContent = () => @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<LinearLayout xmlns:android=""http://schemas.android.com/apk/res/android""
android:orientation = ""vertical""
android:layout_width = ""fill_parent""
android:layout_height = ""fill_parent"">
<unamedproject.CustomTextView
android:id = ""@+id/myText1""
android:layout_width = ""fill_parent""
android:layout_height = ""wrap_content""
android:text = ""namespace_lower"" />
<UnamedProject.CustomTextView
android:id = ""@+id/myText2""
android:layout_width = ""fill_parent""
android:layout_height = ""wrap_content""
android:text = ""namespace_proper"" />
</LinearLayout>"
});
proj.Sources.Add (new BuildItem.Source ("CustomTextView.cs") {
TextContent = () => @"using Android.Widget;
using Android.Content;
using Android.Util;
namespace UnamedProject
{
public class CustomTextView : TextView
{
public CustomTextView(Context context, IAttributeSet attributes) : base(context, attributes)
{
}
}
}"
});
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "first *regular* build should have succeeded.");
var build_props = b.Output.GetIntermediaryPath ("build.props");
var designtime_build_props = b.Output.GetIntermediaryPath (Path.Combine ("designtime", "build.props"));
FileAssert.Exists (build_props, "build.props should exist after a first `Build`.");
FileAssert.DoesNotExist (designtime_build_props, "designtime/build.props should *not* exist after a first `Build`.");
b.Target = "Compile";
Assert.IsTrue (b.Build (proj, parameters: new [] { "DesignTimeBuild=True" }), "first design-time build should have succeeded.");
FileAssert.Exists (build_props, "build.props should exist after a design-time build.");
FileAssert.Exists (designtime_build_props, "designtime/build.props should exist after a design-time build.");
b.Target = "Build";
Assert.IsTrue (b.Build (proj), "second *regular* build should have succeeded.");
FileAssert.Exists (build_props, "build.props should exist after the second `Build`.");
FileAssert.Exists (designtime_build_props, "designtime/build.props should exist after the second `Build`.");
//NOTE: none of these targets should run, since we have not actually changed anything!
var targetsToBeSkipped = new [] {
//TODO: We would like for this assertion to work, but the <Compile /> item group changes between DTB and regular builds
// $(IntermediateOutputPath)designtime\Resource.designer.cs -> Resources\Resource.designer.cs
// And so the built assembly changes between DTB and regular build, triggering `_LinkAssembliesNoShrink`
//"_LinkAssembliesNoShrink",
"_UpdateAndroidResgen",
"_BuildLibraryImportsCache",
"_CompileJava",
};
foreach (var targetName in targetsToBeSkipped) {
Assert.IsTrue (b.Output.IsTargetSkipped (targetName), $"`{targetName}` should be skipped!");
}
b.Target = "Clean";
Assert.IsTrue (b.Build (proj), "clean should have succeeded.");
FileAssert.DoesNotExist (build_props, "build.props should *not* exist after `Clean`.");
FileAssert.Exists (designtime_build_props, "designtime/build.props should exist after `Clean`.");
}
}
[Test]
public void BuildPropsBreaksConvertResourcesCases ([Values (true, false)] bool useAapt2)
{
var proj = new XamarinAndroidApplicationProject () {
AndroidResources = {
new AndroidItem.AndroidResource (() => "Resources\\drawable\\IMALLCAPS.png") {
BinaryContent = () => XamarinAndroidApplicationProject.icon_binary_mdpi,
},
new AndroidItem.AndroidResource ("Resources\\layout\\test.axml") {
TextContent = () => {
return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<ImageView xmlns:android=\"http://schemas.android.com/apk/res/android\" android:src=\"@drawable/IMALLCAPS\" />";
}
}
}
};
proj.SetProperty ("AndroidUseAapt2", useAapt2.ToString ());
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "first build should have succeeded.");
//Invalidate build.props with newer timestamp, you could also modify anything in @(_PropertyCacheItems)
var props = b.Output.GetIntermediaryPath("build.props");
File.SetLastWriteTimeUtc(props, DateTime.UtcNow);
Assert.IsTrue (b.Build (proj), "second build should have succeeded.");
}
}
[Test]
public void AndroidResourceNotExist ()
{
var proj = new XamarinAndroidApplicationProject {
Imports = {
new Import (() => "foo.projitems") {
TextContent = () =>
@"<Project>
<ItemGroup>
<AndroidResource Include=""Resources\layout\noexist.xml"" />
</ItemGroup>
</Project>"
},
},
};
using (var b = CreateApkBuilder ()) {
b.ThrowOnBuildFailure = false;
Assert.IsFalse (b.Build (proj), "Build should have failed.");
Assert.IsTrue (b.LastBuildOutput.ContainsText ("XA2001"), "Should recieve XA2001 error.");
}
}
[Test]
public void TargetFrameworkMonikerAssemblyAttributesPath ()
{
const string filePattern = "MonoAndroid,Version=v*.AssemblyAttributes.cs";
var proj = new XamarinAndroidApplicationProject {
TargetFrameworkVersion = "v6.0",
};
proj.SetProperty ("AndroidUseLatestPlatformSdk", "True");
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (b.Build (proj), "build should have succeeded.");
var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
var old_assemblyattributespath = Path.Combine (intermediate, $"MonoAndroid,Version={proj.TargetFrameworkVersion}.AssemblyAttributes.cs");
FileAssert.DoesNotExist (old_assemblyattributespath, "TargetFrameworkMonikerAssemblyAttributesPath should have the newer TargetFrameworkVersion.");
var new_assemblyattributespath = Directory.EnumerateFiles (intermediate, filePattern).SingleOrDefault ();
Assert.IsNotNull (new_assemblyattributespath, $"A *single* file of pattern {filePattern} should exist in `$(IntermediateOutputPath)`.");
StringAssert.DoesNotContain (proj.TargetFrameworkVersion, File.ReadAllText (new_assemblyattributespath), $"`{new_assemblyattributespath}` should not contain `{proj.TargetFrameworkVersion}`!");
}
}
[Test]
[Category ("dotnet")]
[NonParallelizable]
public void CheckTimestamps ([Values (true, false)] bool isRelease)
{
var start = DateTime.UtcNow.AddSeconds (-1);
var proj = new XamarinFormsAndroidApplicationProject {
IsRelease = isRelease,
};
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
//To be sure we are at a clean state
var projectDir = Path.Combine (Root, b.ProjectDirectory);
if (Directory.Exists (projectDir))
Directory.Delete (projectDir, true);
var intermediate = Path.Combine (projectDir, proj.IntermediateOutputPath);
Assert.IsTrue (b.Build (proj), "first build should have succeeded.");
// None of these files should be *older* than the starting time of this test!
var files = Directory.EnumerateFiles (intermediate, "*", SearchOption.AllDirectories).ToList ();
var linkerOutput = Path.Combine (intermediate, "linked") + Path.DirectorySeparatorChar;
foreach (var file in files) {
//NOTE: ILLink in .NET 5+ currently copies assemblies with older timestamps
if (Builder.UseDotNet && file.StartsWith (linkerOutput)) {
continue;
}
var info = new FileInfo (file);
Assert.IsTrue (info.LastWriteTimeUtc > start, $"`{file}` is older than `{start}`, with a timestamp of `{info.LastWriteTimeUtc}`!");
}
//Build again after a code change (renamed Java.Lang.Object subclass), checking a few files
proj.MainActivity = proj.DefaultMainActivity.Replace ("MainActivity", "MainActivity2");
proj.Touch ("MainActivity.cs");
start = DateTime.UtcNow;
Assert.IsTrue (b.Build (proj), "second build should have succeeded.");
// These files won't exist in OSS Xamarin.Android, thus the existence check and
// Assert.Ignore below. They will also not exist in the commercial version of
// Xamarin.Android unless fastdev is enabled.
foreach (var file in new [] { "typemap.mj", "typemap.jm" }) {
var info = new FileInfo (Path.Combine (intermediate, "android", file));
if (info.Exists) {
Assert.IsTrue (info.LastWriteTimeUtc > start, $"`{file}` is older than `{start}`, with a timestamp of `{info.LastWriteTimeUtc}`!");
}
}
//One last build with no changes
Assert.IsTrue (b.Build (proj), "third build should have succeeded.");
b.Output.AssertTargetIsSkipped (isRelease ? KnownTargets.LinkAssembliesShrink : KnownTargets.LinkAssembliesNoShrink);
b.Output.AssertTargetIsSkipped ("_UpdateAndroidResgen");
b.Output.AssertTargetIsSkipped ("_BuildLibraryImportsCache");
b.Output.AssertTargetIsSkipped ("_CompileJava");
}
}
[Test]
[NonParallelizable] // On MacOS, parallel /restore causes issues
public void BuildApplicationAndClean ([Values (false, true)] bool isRelease, [Values ("apk", "aab")] string packageFormat)
{
var proj = new XamarinFormsAndroidApplicationProject {
IsRelease = isRelease,
};
proj.SetProperty ("AndroidPackageFormat", packageFormat);
if (packageFormat == "aab")
// Disable the shared runtime for aabs because it is not currently compatible and so gives an XA0119 build error.
proj.AndroidUseSharedRuntime = false;
using (var b = CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
Assert.IsTrue (b.Clean (proj), "Clean should have succeeded.");
var ignoreFiles = new string [] {
"TemporaryGeneratedFile",
"FileListAbsolute.txt",
};
var files = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories)
.Where (x => !ignoreFiles.Any (i => !Path.GetFileName (x).Contains (i)));
Assert.AreEqual (0, files.Count (), "{0} should be Empty. Found {1}", proj.IntermediateOutputPath, string.Join (Environment.NewLine, files));
files = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.OutputPath), "*", SearchOption.AllDirectories);
Assert.AreEqual (0, files.Count (), "{0} should be Empty. Found {1}", proj.OutputPath, string.Join (Environment.NewLine, files));
}
}
[Test]
public void BuildApplicationWithLibraryAndClean ([Values (false, true)] bool isRelease)
{
var lib = new XamarinAndroidLibraryProject () {
IsRelease = isRelease,
ProjectName = "Library1",
OtherBuildItems = {
new AndroidItem.AndroidAsset ("Assets\\somefile.txt") {
TextContent = () => "some readonly file...",
Attributes = FileAttributes.ReadOnly,
},
},
};
for (int i = 0; i < 1000; i++) {
lib.OtherBuildItems.Add (new AndroidItem.AndroidAsset (string.Format ("Assets\\somefile{0}.txt", i)) {
TextContent = () => "some readonly file...",
Attributes = FileAttributes.ReadOnly | FileAttributes.Normal,
});
lib.AndroidResources.Add (new AndroidItem.AndroidResource (string.Format ("Resources\\values\\Strings{0}.xml", i)) {
TextContent = () => string.Format (@"<?xml version=""1.0"" encoding=""utf-8""?>
<resources>
<string name=""hello{0}"">Hello World, Click Me! {0}</string>
</resources>", i++),
Attributes = FileAttributes.ReadOnly | FileAttributes.Normal,
});
}
var proj = new XamarinAndroidApplicationProject () {
IsRelease = isRelease,
ProjectName = "App1",
References = { new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj") },
};
var projectPath = Path.Combine ("temp", TestContext.CurrentContext.Test.Name);
using (var libb = CreateDllBuilder (Path.Combine (projectPath, lib.ProjectName), false, false)) {
Assert.IsTrue (libb.Build (lib), "Build of library should have succeeded");
using (var b = CreateApkBuilder (Path.Combine (projectPath, proj.ProjectName), false, false)) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
//var fi = new FileInfo (Path.Combine (b.ProjectDirectory, proj.IntermediateOutputPath,
// "__library_projects__", "Library1", "library_project_imports", ""));
//fi.Attributes != FileAttributes.ReadOnly;
var ignoreFiles = new string [] {
"TemporaryGeneratedFile",
"CopyComplete"
};
Assert.IsTrue (b.Clean (proj), "Clean should have succeeded.");
var fileCount = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories)
.Where (x => !ignoreFiles.Any (i => !Path.GetFileName (x).Contains (i))).Count ();
Assert.AreEqual (0, fileCount, "{0} should be Empty", proj.IntermediateOutputPath);
fileCount = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.OutputPath), "*", SearchOption.AllDirectories)
.Where (x => !ignoreFiles.Any (i => !Path.GetFileName (x).Contains (i))).Count ();
Assert.AreEqual (0, fileCount, "{0} should be Empty", proj.OutputPath);
}
}
}
[Test]
public void BuildIncrementingAssemblyVersion ()
{
var proj = new XamarinAndroidApplicationProject ();
proj.Sources.Add (new BuildItem ("Compile", "AssemblyInfo.cs") {
TextContent = () => "[assembly: System.Reflection.AssemblyVersion (\"1.0.0.*\")]"
});
using (var b = CreateApkBuilder ("temp/BuildIncrementingAssemblyVersion")) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
var acwmapPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "acw-map.txt");
var assemblyPath = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, "UnnamedProject.dll");
var firstAssemblyVersion = AssemblyName.GetAssemblyName (assemblyPath).Version;
var expectedAcwMap = File.ReadAllText (acwmapPath);
b.Target = "Rebuild";
b.BuildLogFile = "rebuild.log";
Assert.IsTrue (b.Build (proj), "Rebuild should have succeeded.");
var secondAssemblyVersion = AssemblyName.GetAssemblyName (assemblyPath).Version;
Assert.AreNotEqual (firstAssemblyVersion, secondAssemblyVersion);
var actualAcwMap = File.ReadAllText (acwmapPath);
Assert.AreEqual (expectedAcwMap, actualAcwMap);
}
}
[Test]
[Category ("dotnet")]
public void BuildIncrementingClassName ()
{
int count = 0;
var source = new BuildItem ("Compile", "World.cs") {
TextContent = () => {
int current = ++count;
return $"namespace Hello{current} {{ public class World{current} : Java.Lang.Object {{ }} }}";
}
};
var proj = new XamarinAndroidApplicationProject ();
proj.Sources.Add (source);
using (var b = CreateApkBuilder ("temp/BuildIncrementingClassName")) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
var classesZipPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "bin", "classes.zip");
FileAssert.Exists (classesZipPath);
var expectedBuilder = new StringBuilder ();
using (var zip = ZipHelper.OpenZip (classesZipPath)) {
foreach (var file in zip) {
expectedBuilder.AppendLine (file.FullName);
}
}
var expectedZip = expectedBuilder.ToString ();
source.Timestamp = null; //Force the file to re-save w/ new Timestamp
Assert.IsTrue (b.Build (proj), "Second build should have succeeded.");
var actualBuilder = new StringBuilder ();
using (var zip = ZipHelper.OpenZip (classesZipPath)) {
foreach (var file in zip) {
actualBuilder.AppendLine (file.FullName);
}
}
var actualZip = actualBuilder.ToString ();
Assert.AreNotEqual (expectedZip, actualZip);
//Build with no changes
Assert.IsTrue (b.Build (proj), "Third build should have succeeded.");
FileAssert.Exists (classesZipPath);
//Clean
Assert.IsTrue (b.Clean (proj), "Clean should have succeeded.");
FileAssert.DoesNotExist (classesZipPath);
}
}
[Test]
public void CSharp8Features ([Values (true, false)] bool bindingProject)
{
XamarinAndroidProject proj;
if (bindingProject) {
proj = new XamarinAndroidBindingProject {
AndroidClassParser = "class-parse",
Jars = {
new AndroidItem.EmbeddedJar ("Jars\\svg-android.jar") {
WebContentFileNameFromAzure = "javaBindingIssue.jar"
}
}
};
} else {
proj = new XamarinAndroidApplicationProject ();
}
proj.Sources.Add (new BuildItem.Source ("Foo.cs") {
TextContent = () => "class A { void B () { using var s = new System.IO.MemoryStream (); } }",
});
using (var b = bindingProject ? CreateDllBuilder () : CreateApkBuilder ()) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
}
}
[Test]
[Category ("SmokeTests")]
public void BuildMkBundleApplicationRelease ()
{
var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true };
using (var b = CreateApkBuilder ("temp/BuildMkBundleApplicationRelease", false)) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
var assemblies = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
"bundles", "armeabi-v7a", "assemblies.o");
Assert.IsTrue (File.Exists (assemblies), "assemblies.o does not exist");
var libapp = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
"bundles", "armeabi-v7a", "libmonodroid_bundle_app.so");
Assert.IsTrue (File.Exists (libapp), "libmonodroid_bundle_app.so does not exist");
var apk = Path.Combine (Root, b.ProjectDirectory,
proj.IntermediateOutputPath, "android", "bin", "UnnamedProject.UnnamedProject.apk");
using (var zipFile = ZipHelper.OpenZip (apk)) {
Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile,
"lib/armeabi-v7a/libmonodroid_bundle_app.so"),
"lib/armeabi-v7a/libmonodroid_bundle_app.so should be in the UnnamedProject.UnnamedProject.apk");
Assert.IsNull (ZipHelper.ReadFileFromZip (zipFile,
Path.Combine ("assemblies", "UnnamedProject.dll")),
"UnnamedProject.dll should not be in the UnnamedProject.UnnamedProject.apk");
}
}
}
[Test]
[Category ("Minor")]
public void BuildMkBundleApplicationReleaseAllAbi ()
{
var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true };
proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86");
using (var b = CreateApkBuilder ("temp/BuildMkBundleApplicationReleaseAllAbi", false)) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
foreach (var abi in new string [] { "armeabi-v7a", "x86" }) {
var assemblies = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
"bundles", abi, "assemblies.o");
Assert.IsTrue (File.Exists (assemblies), abi + " assemblies.o does not exist");
var libapp = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath,
"bundles", abi, "libmonodroid_bundle_app.so");
Assert.IsTrue (File.Exists (libapp), abi + " libmonodroid_bundle_app.so does not exist");
var apk = Path.Combine (Root, b.ProjectDirectory,
proj.IntermediateOutputPath, "android", "bin", "UnnamedProject.UnnamedProject.apk");
using (var zipFile = ZipHelper.OpenZip (apk)) {
Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile,
"lib/" + abi + "/libmonodroid_bundle_app.so"),
"lib/{0}/libmonodroid_bundle_app.so should be in the UnnamedProject.UnnamedProject.apk", abi);
Assert.IsNull (ZipHelper.ReadFileFromZip (zipFile,
Path.Combine ("assemblies", "UnnamedProject.dll")),
"UnnamedProject.dll should not be in the UnnamedProject.UnnamedProject.apk");
}
}
}
}
[Test]
[TestCaseSource (nameof (AotChecks))]
[Category ("SmokeTests")]
public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM, bool expectedResult)
{
var path = Path.Combine ("temp", string.Format ("BuildAotApplication AndÜmläüts_{0}_{1}_{2}", supportedAbis, enableLLVM, expectedResult));
var proj = new XamarinAndroidApplicationProject () {
IsRelease = true,
BundleAssemblies = false,
AotAssemblies = true,
};
proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1");
proj.SetAndroidSupportedAbis (supportedAbis);
proj.SetProperty ("EnableLLVM", enableLLVM.ToString ());
bool checkMinLlvmPath = enableLLVM && (supportedAbis == "armeabi-v7a" || supportedAbis == "x86");
if (checkMinLlvmPath) {
// Set //uses-sdk/@android:minSdkVersion so that LLVM uses the right libc.so
proj.AndroidManifest = $@"<?xml version=""1.0"" encoding=""utf-8""?>
<manifest xmlns:android=""http://schemas.android.com/apk/res/android"" android:versionCode=""1"" android:versionName=""1.0"" package=""{proj.PackageName}"">
<uses-sdk android:minSdkVersion=""{Xamarin.Android.Tools.XABuildConfig.NDKMinimumApiAvailable}"" />
<application android:label=""{proj.ProjectName}"">
</application>
</manifest>";
}