Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions integration-test/android.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ BeforeDiscovery {
}

$cases = @(
@{ configuration = 'Release' }
@{ configuration = 'Debug' }
@{ configuration = 'Release'; runtime = 'mono' }
@{ configuration = 'Debug'; runtime = 'mono' }
)
Describe 'MAUI app (<dotnet_version>, <configuration>)' -ForEach $cases -Skip:(-not $script:emulator) {
# CoreCLR on Android requires .NET 10 or later
if ($dotnet_version -ne 'net9.0') {
$cases += @(
@{ configuration = 'Release'; runtime = 'coreclr' }
@{ configuration = 'Debug'; runtime = 'coreclr' }
)
}
Describe 'MAUI app (<dotnet_version>, <configuration>, <runtime>)' -ForEach $cases -Skip:(-not $script:emulator) {
BeforeAll {
$tfm = "$dotnet_version-android$(GetAndroidTpv $dotnet_version)"

Expand All @@ -38,10 +45,12 @@ Describe 'MAUI app (<dotnet_version>, <configuration>)' -ForEach $cases -Skip:(-
$rid = "android-$arch"

Write-Host "::group::Build Sentry.Maui.Device.IntegrationTestApp.csproj"
$useMonoRuntime = if ($runtime -eq 'mono') { 'true' } else { 'false' }
dotnet build Sentry.Maui.Device.IntegrationTestApp.csproj `
--configuration $configuration `
--framework $tfm `
--runtime $rid
--runtime $rid `
-p:UseMonoRuntime=$useMonoRuntime
| ForEach-Object { Write-Host $_ }
Write-Host '::endgroup::'
$LASTEXITCODE | Should -Be 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.5" />
</ItemGroup>

<!-- Needed for SetAndroidNdkPreload (buildTransitive doesn't apply via ProjectReference) -->
<ImportGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<Import Project="..\..\src\Sentry\buildTransitive\Sentry.props" Condition="Exists('..\..\src\Sentry\buildTransitive\Sentry.props')" />
<Import Project="..\..\src\Sentry\buildTransitive\Sentry.targets" Condition="Exists('..\..\src\Sentry\buildTransitive\Sentry.targets')" />
</ImportGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(LatestAndroidTfm);$(PreviousAndroidTfm)</TargetFrameworks>
<SentryAndroidSdkVersion>8.38.0</SentryAndroidSdkVersion>
<SentryAndroidSdkVersion>8.39.0</SentryAndroidSdkVersion>
<SentryAndroidSdkDirectory>$(BaseIntermediateOutputPath)sdks\$(TargetFramework)\Sentry\Android\$(SentryAndroidSdkVersion)\</SentryAndroidSdkDirectory>
<!-- This gets resolved by the DownloadSentryAndroidSdk unless using local maven references -->
<SentryNativeNdkVersion></SentryNativeNdkVersion>
Expand Down
8 changes: 8 additions & 0 deletions src/Sentry/Platforms/Android/SentrySdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ private static void InitSentryAndroidSdk(SentryOptions options)
o.ShutdownTimeoutMillis = (long)options.ShutdownTimeout.TotalMilliseconds;

var signalHandlerStrategy = options.Native.ExperimentalOptions.SignalHandlerStrategy;
if (signalHandlerStrategy == SignalHandlerStrategy.ChainAtStart
&& Type.GetType("Mono.RuntimeStructs") == null)
{
options.LogInfo(
"Using SignalHandlerStrategy.Default on .NET CoreCLR. " +
"SignalHandlerStrategy.ChainAtStart is only required on the Mono runtime.");
signalHandlerStrategy = SignalHandlerStrategy.Default;
Comment thread
jpnurmi marked this conversation as resolved.
}
if (signalHandlerStrategy == SignalHandlerStrategy.ChainAtStart
&& System.Environment.Version is { Major: 10, Minor: 0, Build: < 4 })
{
Expand Down
1 change: 1 addition & 0 deletions src/Sentry/buildTransitive/Sentry.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<_SentryTargetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</_SentryTargetFrameworkVersion>
<_SentryIsNet8OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 8.0))</_SentryIsNet8OrGreater>
<_SentryIsNet9OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 9.0))</_SentryIsNet9OrGreater>
<_SentryIsNet10OrGreater>$([MSBuild]::VersionGreaterThanOrEquals($(_SentryTargetFrameworkVersion), 10.0))</_SentryIsNet10OrGreater>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions src/Sentry/buildTransitive/Sentry.targets
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@
</ItemGroup>
</Target>

<!-- Preload NDK to ensure sentry-native's signal handlers are installed before .NET runtime's.
Disabled on Mono until: https://github.com/dotnet/runtime/pull/125835 -->
<Target Name="SetAndroidNdkPreload"
BeforeTargets="GetAssemblyAttributes"
Condition="'$(AndroidApplication)' == 'True'
and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'
and '$(_SentryIsNet10OrGreater)' == 'true'
and '$(UseMonoRuntime)' != 'true'">
<ItemGroup>
<AssemblyAttribute Include="Android.App.MetaData">
<_Parameter1>io.sentry.ndk.preload</_Parameter1>
<Value>true</Value>
</AssemblyAttribute>
</ItemGroup>
</Target>

<!-- Upload Android ProGuard mapping file to Sentry after the build. -->
<Target Name="UploadAndroidProGuardMappingFileToSentry" AfterTargets="Build" DependsOnTargets="PrepareSentryCLI"
Condition="'$(SentryCLI)' != '' and '$(SentryUploadAndroidProGuardMapping)' == 'true' And '$(AndroidProguardMappingFile)' != ''">
Expand Down
Loading