Skip to content

[build] Build Xamarin.Android.NUnitLite.dll for API-10 - #2190

Merged
jonpryor merged 1 commit into
dotnet:masterfrom
jonpryor:jonp-fix-2189
Sep 18, 2018
Merged

jonpryor merged 1 commit into
dotnet:masterfrom
jonpryor:jonp-fix-2189

Conversation

@jonpryor

Copy link
Copy Markdown
Contributor

Context: 24158d0
Fixes: #2189

What do we want? A reliable way to get TestResults.xml files off of
the Android target device, so that we can get unit test results.
A reliable way that works on a variety of Android API levels and their
corresponding emulators.

(What do we want? GREEN BUILDS.)

The problem with 24158d0 is twofold:

  1. When building an app with a $(TargetFrameworkVersion) less than
    v9.0 ($(lastword $(API_LEVELS))), there is a build warning:

    warning XA0105: The $(TargetFrameworkVersion) for 'Foo' (v9.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0). You need to increase the $(TargetFrameworkVersion) for your project.
    
  2. When running/using Xamarin.Android.NUnitLite.dll on an API-10
    device/pre-API-21 device, there is a runtime error.

(1) is ignorable, -ish.

(2) is not:

FATAL EXCEPTION: main
Process: Xamarin.Android.Locale_Tests, PID: 12615
android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not resolve type with token 010000d4 from typeref (expected class 'Android.OS.BaseBundle' in assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065')
  at Xamarin.Android.NUnitLite.AndroidRunner.GetSetupTestTarget (Android.Content.Intent intent) [0x00000] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/AndroidRunner.cs:345
  at Xamarin.Android.NUnitLite.TestSuiteActivity.SetupTestTarget () [0x00008] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:246
  at Xamarin.Android.NUnitLite.TestSuiteActivity.UpdateData (Android.Runtime.JavaList`1[T] data, Android.Widget.ListView lv) [0x00006] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:137
  at Xamarin.Android.NUnitLite.TestSuiteActivity.OnCreate (Android.OS.Bundle bundle) [0x0003b] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:49
  at Xamarin.Android.LocaleTests.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0000d] in C:\Users\peter\source\monodroid\external\xamarin-android\tests\locales\Xamarin.Android.Locale-Tests\MainActivity.cs:19

Consequently, while 24158d0 gave us a green Jenkins job, the
resulting assembly is not usable when run on Android devices < API-21.

The fix? Partially revert 24158d0 so that
Xamarin.Android.NUnitLite.dll is once again built against
$(firstword $(API_LEVELS)), i.e. API-10, and instead update
Xamarin.Android.NUnitLite.dll so that instead of using
Environment.DirectoryDocuments -- which only exists in API-19+ -- we
use Environment.DirectoryDownloads on pre-API-19 devices.

Let's see if this works!

@jonpryor jonpryor added the full-mono-integration-build For PRs; run a full build (~6-10h for mono bumps), not the faster PR subset (~2h for mono bumps) label Sep 17, 2018
@jonpryor
jonpryor requested a review from grendello September 17, 2018 21:47
Context: 24158d0
Fixes: dotnet#2189

What do we want?  A reliable way to get `TestResults.xml` files off of
the Android target device, so that we can get unit test results.
A reliable way that works on a variety of Android API levels and their
corresponding emulators.

(What do we want?  ***GREEN BUILDS***.)

The problem with 24158d0 is twofold:

 1. When building an app with a `$(TargetFrameworkVersion)` less than
    `v9.0` (`$(lastword $(API_LEVELS))`), there is a build warning:

        warning XA0105: The $(TargetFrameworkVersion) for 'Foo' (v9.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0). You need to increase the $(TargetFrameworkVersion) for your project.

 2. When *running*/using `Xamarin.Android.NUnitLite.dll` on an API-10
    device/pre-API-21 device, there is a *runtime* error.

(1) is ignorable, -ish.

(2) is not:

	FATAL EXCEPTION: main
	Process: Xamarin.Android.Locale_Tests, PID: 12615
	android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not resolve type with token 010000d4 from typeref (expected class 'Android.OS.BaseBundle' in assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065')
	  at Xamarin.Android.NUnitLite.AndroidRunner.GetSetupTestTarget (Android.Content.Intent intent) [0x00000] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/AndroidRunner.cs:345
	  at Xamarin.Android.NUnitLite.TestSuiteActivity.SetupTestTarget () [0x00008] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:246
	  at Xamarin.Android.NUnitLite.TestSuiteActivity.UpdateData (Android.Runtime.JavaList`1[T] data, Android.Widget.ListView lv) [0x00006] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:137
	  at Xamarin.Android.NUnitLite.TestSuiteActivity.OnCreate (Android.OS.Bundle bundle) [0x0003b] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:49
	  at Xamarin.Android.LocaleTests.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0000d] in C:\Users\peter\source\monodroid\external\xamarin-android\tests\locales\Xamarin.Android.Locale-Tests\MainActivity.cs:19

Consequently, while 24158d0 gave *us* a green Jenkins job, the
resulting assembly is not usable when run on Android devices < API-21.

The fix?  Partially revert 24158d0 so that
`Xamarin.Android.NUnitLite.dll` is once again built against
`$(firstword $(API_LEVELS))`, i.e. API-10, and instead update
`Xamarin.Android.NUnitLite.dll` so that instead of using
`Environment.DirectoryDocuments` -- which only exists in API-19+ -- we
use `Environment.DirectoryDownloads` on pre-API-19 devices.

Let's see if this works!
@jonpryor jonpryor changed the title [build] Build Xamarin.Android.NUnitLite.dll for API-28 [build] Build Xamarin.Android.NUnitLite.dll for API-10 Sep 18, 2018
@jonpryor

Copy link
Copy Markdown
Contributor Author

The build failure in the macOS PR Build is:

xamarin-android/external/Java.Interop/build-tools/scripts/RunNUnitTests.targets(35,5): error MSB3073: The command "mono --debug packages/NUnit.ConsoleRunner.3.7.0/tools/nunit3-console.exe  /Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/external/Java.Interop/build-tools/scripts/../../bin/TestRelease/Java.Interop.Dynamic-Tests.dll  --result="TestResult-Java.Interop.Dynamic-Tests.xml;format=nunit2" --output="bin/TestRelease/TestOutput-Java.Interop.Dynamic-Tests.txt"" exited with code -1.

This is because mono crashed:

RunTests:
  mono --debug packages/NUnit.ConsoleRunner.3.7.0/tools/nunit3-console.exe  /Users/builder/jenkins/workspace/xamarin-android-pr-builder/xamarin-android/external/Java.Interop/build-tools/scripts/../../bin/TestRelease/Java.Interop.Dynamic-Tests.dll  --result="TestResult-Java.Interop.Dynam
ic-Tests.xml;format=nunit2" --output="bin/TestRelease/TestOutput-Java.Interop.Dynamic-Tests.txt"
  NUnit Console Runner 3.7.0 
...
  WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
  
  Stacktrace:
  
    at <unknown> <0xffffffff>
    at System.Net.Sockets.Socket.Dispose (bool) [0x00037] in <1ee22316918743dabf254ca17b81e7f5>:0
    at System.Net.Sockets.Socket.Dispose () [0x00000] in <1ee22316918743dabf254ca17b81e7f5>:0
    at System.Net.Sockets.Socket.Close () [0x00007] in <1ee22316918743dabf254ca17b81e7f5>:0
    at System.Runtime.Remoting.Channels.Tcp.ClientConnection.ProcessMessages () [0x00074] in <031b30687aa5463a8ff1010bc5f2d2a4>:0
    at System.Runtime.Remoting.Channels.RemotingThreadPool.PoolThread () [0x000cb] in <031b30687aa5463a8ff1010bc5f2d2a4>:0
...
  Native stacktrace:
  
        0   mono                                0x000000010a089548 mono_handle_native_crash + 264
        1   mono                                0x000000010a0f3af6 altstack_handle_and_restore + 70
        2   mono                                0x000000010a06f573 mono_aot_get_cached_class_info + 19
        3   mono                                0x000000010a1562df mono_class_is_subclass_of + 31
        4   libjava-interop.dylib               0x0000000111bf4908 get_gc_bridge_index + 120
        5   libjava-interop.dylib               0x0000000111bf424c gc_bridge_class_kind + 60
...
  =================================================================
  Got a SIGSEGV while executing native code. This usually indicates
  a fatal error in the mono runtime or one of the native libraries 
  used by your application.
  =================================================================

This crash is unrelated to changes in Xamarin.Android.NUnitLite.dll, as that test doesn't use Xamarin.Android.NUnitLite.dll.

What's somewhat odd is that the build log mentions two errors, but I would expect the above crash to only count as one...

@jonpryor
jonpryor merged commit 37c5577 into dotnet:master Sep 18, 2018
jonpryor added a commit that referenced this pull request Oct 2, 2018
Fixes: #2189
Context: 8e4ed45

What do we want?  A reliable way to get `TestResults.xml` files off of
the Android target device, so that we can get unit test results.
A reliable way that works on a variety of Android API levels and their
corresponding emulators.

(What do we want?  ***GREEN BUILDS***.)

The problem with 8e4ed45 is twofold:

 1. When building an app with a `$(TargetFrameworkVersion)` less than
    `v9.0` (`$(lastword $(API_LEVELS))`), there is a build warning:

        warning XA0105: The $(TargetFrameworkVersion) for 'Foo' (v9.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0). You need to increase the $(TargetFrameworkVersion) for your project.

 2. When *running*/using `Xamarin.Android.NUnitLite.dll` on an API-10
    device/pre-API-21 device, there is a *runtime* error.

(1) is ignorable, -ish.

(2) is not:

	FATAL EXCEPTION: main
	Process: Xamarin.Android.Locale_Tests, PID: 12615
	android.runtime.JavaProxyThrowable: System.TypeLoadException: Could not resolve type with token 010000d4 from typeref (expected class 'Android.OS.BaseBundle' in assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065')
	  at Xamarin.Android.NUnitLite.AndroidRunner.GetSetupTestTarget (Android.Content.Intent intent) [0x00000] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/AndroidRunner.cs:345
	  at Xamarin.Android.NUnitLite.TestSuiteActivity.SetupTestTarget () [0x00008] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:246
	  at Xamarin.Android.NUnitLite.TestSuiteActivity.UpdateData (Android.Runtime.JavaList`1[T] data, Android.Widget.ListView lv) [0x00006] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:137
	  at Xamarin.Android.NUnitLite.TestSuiteActivity.OnCreate (Android.OS.Bundle bundle) [0x0003b] in /Users/builder/data/lanes/6102/d2851781/source/monodroid/external/xamarin-android/src/Xamarin.Android.NUnitLite/Gui/Activities/TestSuiteActivity.cs:49
	  at Xamarin.Android.LocaleTests.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0000d] in C:\Users\peter\source\monodroid\external\xamarin-android\tests\locales\Xamarin.Android.Locale-Tests\MainActivity.cs:19

Consequently, while 8e4ed45 gave *us* a green Jenkins job, the
resulting assembly is not usable when run on Android devices < API-21.

The fix?  Partially revert 8e4ed45 so that
`Xamarin.Android.NUnitLite.dll` is once again built against
`$(firstword $(API_LEVELS))`, i.e. API-10, and instead update
`Xamarin.Android.NUnitLite.dll` so that instead of using
`Environment.DirectoryDocuments` -- which only exists in API-19+ -- we
use `Environment.DirectoryDownloads` on pre-API-19 devices.
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

full-mono-integration-build For PRs; run a full build (~6-10h for mono bumps), not the faster PR subset (~2h for mono bumps)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update to Build Xamarin.Android.NUnitLite.dll for API-28 introduces possible breakage for existing XA Unit Test Apps

2 participants