Skip to content

Commit 3ed220d

Browse files
radekdoulikjonpryor
authored andcommitted
[nunit] build X.A.NUnitLite.dll with API level 19 (#547)
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=53418 Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=53884 - current NUnitLite was built with latest API level. that was problematic, because it was referencing BaseBundle class, which is only available in API >= 21, see https://developer.android.com/reference/android/os/BaseBundle.html - so instead of using latest API, we now build it with API 19. that's the lowes API level we can use, because src/Xamarin.Android.NUnitLite/Gui/Instrumentations/TestSuiteInstrumentation.cs is using global::Android.OS.Environment.DirectoryDocuments which is avalable in API level >= 19, see https://developer.android.com/reference/android/os/Environment.html#DIRECTORY_DOCUMENTS - also the X.A.Build.Tasks project reference is now conditional, because it requires API level >= 24. it is OK, because we build it in leeroy-all rule with latest API level and default build uses latest API level too. the project reference itself is there to ensure the build ordering, so we can safely make it conditional
1 parent a08cd80 commit 3ed220d

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

build-tools/scripts/BuildEverything.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ framework-assemblies:
103103
$(MSBUILD) $(MSBUILD_FLAGS) src/Mono.Android/Mono.Android.csproj /p:Configuration=$(conf) $(_MSBUILD_ARGS) /p:AndroidApiLevel=$${a} /p:AndroidFrameworkVersion=$${CUR_VERSION} /p:AndroidPreviousFrameworkVersion=$${PREV_VERSION}; ) \
104104
PREV_VERSION=$${CUR_VERSION}; \
105105
done
106+
$(foreach conf, $(CONFIGURATIONS), \
107+
rm -f bin/$(conf)/lib/xbuild-frameworks/MonoAndroid/v1.0/Xamarin.Android.NUnitLite.dll; \
108+
$(MSBUILD) $(MSBUILD_FLAGS) src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj /p:Configuration=$(conf) $(_MSBUILD_ARGS) /p:AndroidApiLevel=19 /p:AndroidFrameworkVersion=v4.4; )
106109

107110
runtime-libraries:
108111
$(foreach conf, $(CONFIGURATIONS), \

src/Xamarin.Android.NUnitLite/Gui/Instrumentations/TestSuiteInstrumentation.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ public override void OnStart ()
9393

9494
string GetResultsPath ()
9595
{
96-
var resultsPathFile = Context.GetExternalFilesDir (global::Android.OS.Environment.DirectoryDocuments);
96+
Java.IO.File resultsPathFile = null;
97+
#if __ANDROID_19__
98+
if (((int)Build.VERSION.SdkInt) >= 19)
99+
resultsPathFile = Context.GetExternalFilesDir (global::Android.OS.Environment.DirectoryDocuments);
100+
#endif
97101
var usePathFile = resultsPathFile != null && resultsPathFile.Exists ();
98102
var resultsPath = usePathFile
99103
? resultsPathFile.AbsolutePath

src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@
353353
<Name>Mono.Android</Name>
354354
<Private>False</Private>
355355
</ProjectReference>
356-
<ProjectReference Include="..\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj">
356+
<ProjectReference Condition=" '$(AndroidApiLevel)' >= 24 " Include="..\Xamarin.Android.Build.Tasks\Xamarin.Android.Build.Tasks.csproj">
357357
<Project>{3F1F2F50-AF1A-4A5A-BEDB-193372F068D7}</Project>
358358
<Name>Xamarin.Android.Build.Tasks</Name>
359359
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>

0 commit comments

Comments
 (0)