You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Define version constraints for sentry-android-fragment #2025
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.
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.
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?
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)
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.
Activity
marandaneto commentedon May 9, 2022
Does it help if we stop using
fragment-ktxand use onlyfragment?marandaneto commentedon May 9, 2022
For dependency constraints, we'd need to support Gradle Module Metadata, so it'd not work if using another build system, I guess.
romtsn commentedon May 9, 2022
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
fragmentwould help for this particular case, but again can be a problem, if someone is usingviewmodel-ktxof an older version, where this class is still present.marandaneto commentedon May 9, 2022
Then it's an error on their end since we don't use
ViewModelLazyKt, right?romtsn commentedon May 9, 2022
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 bumpingfragment-ktx, but needs a mention in the migration docs with a min supported version ofviewmodel-ktxthen)bruno-garcia commentedon Jun 15, 2022
We decided to add a troubleshooting page entry for this
romtsn commentedon Jul 19, 2022
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.