Skip to content

Package downgrades for Xamarin.AndroidX.Lifecycle.Common.Java8 #4095

Closed
getsentry/sentry-docs
#13763

Description

@Cheesebaron

Package

Sentry

.NET Flavor

.NET

.NET Version

9.0.202

OS

Android

OS Version

No response

Development Environment

Rider 2024 (MacOS)

SDK Version

5.5.1

Self-Hosted Sentry Version

No response

Workload Versions

Installed Workload Id Manifest Version Installation Source

android 35.0.39/9.0.100 SDK 9.0.200
ios 18.2.9180/9.0.100 SDK 9.0.200
maccatalyst 18.2.9180/9.0.100 SDK 9.0.200
macos 15.1.9163/9.0.100 SDK 9.0.200
maui 9.0.20/9.0.100 SDK 9.0.200
tvos 18.2.9173/9.0.100 SDK 9.0.200
wasm-tools 9.0.2/9.0.100 SDK 9.0.200

UseSentry or SentrySdk.Init call

NA

Steps to Reproduce

  1. Have a dependency on Xamarin.AndroidX.Lifecycle.Common 2.8.7.2
  2. Update Sentry to 5.5.1
<PackageVersion Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.7.2" />
<PackageVersion Include="Sentry" Version="5.5.1" />

Expected Result

Sentry should upgrade nicely

Actual Result

When upgrading from 5.5.0 to 5.5.1 we now get package downgrade errors:

D:\a\1\s\src\Sentry.Mobile\Sentry.Mobile.csproj : error NU1608: Warning As Error: Detected package version outside of dependency constraint: Xamarin.AndroidX.Lifecycle.Process 2.8.5.1 requires Xamarin.AndroidX.Lifecycle.Runtime (>= 2.8.5.1 && < 2.8.6) but version Xamarin.AndroidX.Lifecycle.Runtime 2.8.7.2 was resolved. [D:\a\1\s\KioskMDM.sln]
D:\a\1\s\src\Sentry.Mobile\Sentry.Mobile.csproj : error NU1107: Version conflict detected for Xamarin.AndroidX.Lifecycle.Common. Install/reference Xamarin.AndroidX.Lifecycle.Common 2.8.7.2 directly to project Sentry.Mobile to resolve this issue.  [D:\a\1\s\KioskMDM.sln]
D:\a\1\s\src\Sentry.Mobile\Sentry.Mobile.csproj : error NU1107:  Sentry.Mobile -> Microsoft.Maui.Essentials 9.0.50 -> Xamarin.AndroidX.Browser 1.8.0.8 -> Xamarin.AndroidX.Core 1.15.0.2 -> Xamarin.AndroidX.Lifecycle.Runtime 2.8.7.2 -> Xamarin.AndroidX.Lifecycle.Common (>= 2.8.7.2 && < 2.8.8)  [D:\a\1\s\KioskMDM.sln]
D:\a\1\s\src\Sentry.Mobile\Sentry.Mobile.csproj : error NU1107:  Sentry.Mobile -> Sentry.Extensions.Logging 5.5.1 -> Sentry 5.5.1 -> Sentry.Bindings.Android 5.5.1 -> Xamarin.AndroidX.Lifecycle.Common.Java8 2.8.5.1 -> Xamarin.AndroidX.Lifecycle.Common (>= 2.8.5.1 && < 2.8.6). [D:\a\1\s\KioskMDM.sln]
  Failed to restore D:\a\1\s\src\Sentry.Mobile\Sentry.Mobile.csproj (in 7.12 sec).

Adding Xamarin.AndroidX.Lifecycle.Common directly to the Sentry.Mobile project does not solve the issue.

The dependency on Xamarin.AndroidX.Lifecycle.Common.Java8 seems to be new, and is very restrictive of which version of Lifecycle packages you can install.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 9, 2025
  2. jamescrosswell commented on Apr 9, 2025

    @jamescrosswell
    Collaborator

    We include these dependencies here in Sentry.Bindings.Android.csproj:

    <!-- Dependencies for AndroidMavenLibrary references
    Note: versions match what was shipped with net9.0-android35.0 in:
    https://www.nuget.org/packages/Microsoft.Maui.Core/9.0.0#dependencies-body-tab
    -->
    <ItemGroup Condition="$(TargetFramework.StartsWith('net9'))">
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.8.5.1" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common.Java8" Version="2.8.5.1" />
    <!-- MAUI 9 references this version indirectly via Xamarin.AndroidX.SwipeRefreshLayout (>= 1.1.0.24) -->
    <PackageReference Include="Xamarin.AndroidX.Core" Version="1.13.1.5" />
    </ItemGroup>

    They are dependencies of the Java SDK that we reference:

    <AndroidLibrary
    Include="$(SentryAndroidSdkDirectory)sentry-$(SentryAndroidSdkVersion).jar"
    Manifest="$(SentryAndroidSdkDirectory)sentry-$(SentryAndroidSdkVersion).pom"
    JavaArtifact="io.sentry:sentry:$(SentryAndroidSdkVersion)"
    />
    <AndroidMavenLibrary Include="io.sentry:sentry-android-core" Version="$(SentryAndroidSdkVersion)" />
    <AndroidMavenLibrary Include="io.sentry:sentry-android-ndk" Version="$(SentryAndroidSdkVersion)" />

    We should probably be allowing a range there, so something like:

        <PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="[2.8.5.1,)" />
        <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common.Java8" Version="[2.8.5.1,)" />
        <!-- MAUI 9 references this version indirectly via Xamarin.AndroidX.SwipeRefreshLayout (>= 1.1.0.24)   -->
        <PackageReference Include="Xamarin.AndroidX.Core" Version="[1.13.1.5,)" />
  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 9, 2025
  4. jamescrosswell commented on Apr 9, 2025

    @jamescrosswell
    Collaborator

    We should probably be allowing a range there, so something like:

    <PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="[2.8.5.1,)" />
    <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common.Java8" Version="[2.8.5.1,)" />
    <!-- MAUI 9 references this version indirectly via Xamarin.AndroidX.SwipeRefreshLayout (>= 1.1.0.24)   -->
    <PackageReference Include="Xamarin.AndroidX.Core" Version="[1.13.1.5,)" />
    

    Hm, tricky. We don't seem to be able to do that:

    Xamarin.Android.Bindings.JavaDependencyVerification.targets(27,5): Error XAJDV7004 : System.ArgumentException: '[2.8.5.1,)' is not a valid version string. (Parameter 'value')

  5. Cheesebaron commented on Apr 9, 2025

    @Cheesebaron
    ContributorAuthor

    So I have these dependencies which have their respective dependencies:

    • Microsoft.Maui.Essentials 9.0.50
      • Xamarin.AndroidX.Browser 1.8.0.8
        • Xamarin.AndroidX.Core 1.15.0.2
          • Xamarin.AndroidX.Lifecycle.Runtime 2.8.7.2.

    The App I run also uses bits of Xamarin.AndroidX.Lifecycle. So that is why I am using this specific version.

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 9, 2025
  7. jamescrosswell commented on Apr 9, 2025

    @jamescrosswell
    Collaborator

    OK. It looks like a classic diamond dependency problem:

    Sentry.Bindings.Android 5.5.1 -> Xamarin.AndroidX.Lifecycle.Common.Java8 2.8.5.1 -> Xamarin.AndroidX.Lifecycle.Common (>= 2.8.5.1 && < 2.8.6)
    Microsoft.Maui.Essentials 9.0.50 -> Xamarin.AndroidX.Browser 1.8.0.8 -> Xamarin.AndroidX.Core 1.15.0.2 -> Xamarin.AndroidX.Lifecycle.Runtime 2.8.7.2 -> Xamarin.AndroidX.Lifecycle.Common (>= 2.8.7.2 && < 2.8.8)
    

    I wonder if it's possible for you to tell NuGet to use newer versions of the dependencies Sentry needs by including these in your csproj explicitly (rather than rely on NuGet's transitive dependency resolution). For example:

         <PackageReference Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.8.7.2" /> 
         <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common.Java8" Version="2.8.7.2" /> 
         <PackageReference Include="Xamarin.AndroidX.Core" Version="1.15.0.2" /> 
    

    That's all of Sentry's dependencies, but with versions that would (hopefully) be compatible with Microsoft.Maui.Essentials 9.0.50.

  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 9, 2025
  9. MAUIoxo commented on Apr 11, 2025

    @MAUIoxo

    I also face this issue after upgrading to .NET MAUI 9.0.60.
    Compile works with Sentry 5.5.0 and not with 5.5.1.

    To be honest, did not expect this with an update to a newer patch version 5.5.x

    Version conflict detected for Xamarin.AndroidX.Lifecycle.Common. Install/reference Xamarin.AndroidX.Lifecycle.Common 2.8.7.2 directly to project MyApp to resolve this issue. 
     MyApp -> Microsoft.Maui.Controls 9.0.60 -> Microsoft.Maui.Controls.Core 9.0.60 -> Microsoft.Maui.Core 9.0.60 -> Xamarin.AndroidX.Navigation.Common 2.8.5.1 -> Xamarin.AndroidX.Lifecycle.Common (>= 2.8.7.2) 
     MyApp -> Sentry 5.5.1 -> Sentry.Bindings.Android 5.5.1 -> Xamarin.AndroidX.Lifecycle.Common.Java8 2.8.5.1 -> Xamarin.AndroidX.Lifecycle.Common (>= 2.8.5.1 && < 2.8.6)
    
  10. 48 remaining items

  11. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 28, 2025
  12. albyrock87 commented on May 13, 2025

    @albyrock87
    Contributor

    Heads up, a new upgrade has just landed on main pointing to 2.8.7.3.
    It will be included in SR8.
    dotnet/maui@f65f1ea

    On the FAQ I think it's better to suggest a separate ItemGroup like this:

    <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
        <!-- https://github.com/getsentry/sentry-dotnet/issues/4095 -->
        <!-- IMPORTANT: keep this in sync with Xamarin.AndroidX.Lifecycle.LiveData https://github.com/dotnet/maui/blob/main/eng/AndroidX.targets#L15-L18 -->
        <PackageReference Include="Xamarin.AndroidX.Lifecycle.Common.Java8" Version="2.8.7.2" />
        <PackageVersion Include="Xamarin.AndroidX.Lifecycle.Process" Version="2.8.7.2" />
    </ItemGroup>
    
  13. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on May 13, 2025
  14. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 14, 2025
  15. bruno-garcia commented on May 14, 2025

    @bruno-garcia
    Member

    Is there a way we can work with the MAUI team to improve this situation? (sorry, drive by feedback as I’m not well educated in the details).
    @Redth might have ideas

  16. aritchie commented on May 14, 2025

    @aritchie
    Contributor

    @bruno-garcia my PR takes care of the issue. The goal is for our library to go back as far as it can. MAUI will pull us forward on whatever version they want to use. The reason this PR hasn't gone through was due to the issues we kept having with CI

  17. jamescrosswell commented on May 16, 2025

    @jamescrosswell
    Collaborator

    I also left a comment on that other PR (a way we could potentially test the change, by using one of the dependencies the folks on this thread are having trouble with).

    Unfortunately that PR doesn't resolve the issue.

    Is there a way we can work with the MAUI team to improve this situation? (sorry, drive by feedback as I’m not well educated in the details).
    @Redth might have ideas

    Other than statically linking dependencies (not an option when the dependencies are the Android APIs), diamond dependency issues are a pretty tough nut to crack.

    The only solution I can think of would be if the entire .NET community aligned on the versions of dependencies that they would target... implicitly that's what we do every year to build support for the .NET runtime. MS make some breaking changes in .NET 9, for example, and everyone's SDK and applications get updated (making all the necessary breaking changes) and we're happy with that until the next set of breaking changes that require another major version release.

    @Redth the situation could be alleviated if MS locked the versions of Java depdendencies that are used by the .NET workloads (and by stuff like the Community Toolkit) with every new major release of .NET.... that way all of the SDKs and applications in the .NET community could align on the versions of those dependencies as at the time of the release of the TFM they're building to and everything would keep ticking over until the next major .NET release.

    At the moment, that's not happening. New point releases of MAUI workloads are bumping versions of the Java dependencies. In some situations work arounds might be available. We're fortunate enough at Sentry that we're not heavily using the Android APIs and so we only have a minimum version constraint (no upper bound)... I think those workarounds should always work where our SDK specifically is concerned then. But I don't think there are any guarantees those workarounds will work in all situations

  18. jamescrosswell commented on May 20, 2025

    @jamescrosswell
    Collaborator

    PR to add troubleshooting documentation here, for anyone who is interested:

    @albyrock87 regarding your comment, the specific solution will depend on the other NuGets people are referencing. It wasn't really possible to provide code that people could copy/paste then... instead I'm hoping the article explains things well enough that people will be able to find a solution that works in their specific circumstances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions