Skip to content

Define version constraints for sentry-android-fragment #2025

Closed

Description

@romtsn

Description

The sentry-android-fragment module depends on androidx.fragment:fragment-ktx. This one, in turn, depends on androidx.lifecycle:lifecycle-viewmodel-ktx, which had at some point the following change (moving ViewModelLazyKt from viewmodel-ktx to viewmodel):

This change can cause Duplicate classes check to fail if the versions of androidx.lifecycle:viewmodel and androidx.lifecycle:viewmodel-ktx do not much (e.g. viewmodel comes as a transitive dependency with a higher version than viewmodel-ktx, where this change has been introduced).

In theory, we could mitigate this issue by declaring dependency constraints for androidx.fragment:fragment-ktx, where we can define a range of allowed transitive dependency versions (viewmodel-ktx in this case).

Encountered this issue when using our SAGP auto-installation feature on this sample project.

Activity

  1. marandaneto commented on May 9, 2022

    @marandaneto
    Contributor

    Does it help if we stop using fragment-ktx and use only fragment?

  2. marandaneto commented on May 9, 2022

    @marandaneto
    Contributor

    For dependency constraints, we'd need to support Gradle Module Metadata, so it'd not work if using another build system, I guess.

  3. romtsn commented on May 9, 2022

    @romtsn
    ContributorAuthor

    Yeah, but not sure if it's a problem in other build systems (probably it is, but the fraction of those is just too small). So I guess we are good here with just doing it for gradle.

    Using fragment would help for this particular case, but again can be a problem, if someone is using viewmodel-ktx of an older version, where this class is still present.

  4. marandaneto commented on May 9, 2022

    @marandaneto
    Contributor

    Using fragment would help for this particular case, but again can be a problem, if someone is using viewmodel-ktx of an older version, where this class is still present.

    Then it's an error on their end since we don't use ViewModelLazyKt, right?

  5. romtsn commented on May 9, 2022

    @romtsn
    ContributorAuthor

    yeah, kinda. They would need to update their viewmodel-ktx to the later version. I mean, this can be fixed on the user's site even now, by declaring the explicit dependency to viewmodel-ktx, I just thought of a nice way to prevent this issue for the consumers. Can be low priority for sure (or can be resolved by bumping fragment-ktx, but needs a mention in the migration docs with a min supported version of viewmodel-ktx then)

  6. bruno-garcia commented on Jun 15, 2022

    @bruno-garcia
    Member

    We decided to add a troubleshooting page entry for this

  7. romtsn commented on Jul 19, 2022

    @romtsn
    ContributorAuthor

    So this was actually resolved by #2175 as we declare the transitive dependencies as compileOnly now, and will use whatever the user has defined in their app at runtime, so this problem will not appear anymore.

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions