Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Android): Fix error about duplicate class ViewModelLazy #1977

Merged
merged 5 commits into from
Nov 29, 2023

Conversation

tboba
Copy link
Member

@tboba tboba commented Nov 23, 2023

Description

Users are reporting that they are receiving error while building their project with react-native-screens 3.27.0:

> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.2.0-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0) and lifecycle-viewmodel-2.5.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.0)

This error is fairly easy to fix and is related to the wrong imports of dependencies in gradle.
Closes #1947.

Changes

  • Added import for lifecycle-viewmodel and lifecycle-viewmodel-ktx (these two imports are necessary, as lifecycle-viewmodel evokes error for lifecycle-viewmodel-ktx.

Checklist

  • Ensured that CI passes

@tboba tboba changed the title Fix error about duplicate class ViewModelLazy fix(Android): Fix error about duplicate class ViewModelLazy Nov 23, 2023
Comment on lines 133 to 134
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I checked those deps right now I observed that "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0" could be sufficient, but in my opinion we should ensure that both of these libraries should have the same version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

androidx.lifecycle:licecycle-viewmodel:2.5.0 is a direct dependency of androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0. There is no need to specify it.

See here: https://androidx.tech/artifacts/lifecycle/lifecycle-viewmodel-ktx/2.5.0

@tboba tboba requested a review from kkafar November 24, 2023 12:54
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I've checked the dependency graph & it seems that 2.5.1 should be fine.

Nevertheless I've left a nitpick below :D

Comment on lines 133 to 134
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

androidx.lifecycle:licecycle-viewmodel:2.5.0 is a direct dependency of androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0. There is no need to specify it.

See here: https://androidx.tech/artifacts/lifecycle/lifecycle-viewmodel-ktx/2.5.0

android/build.gradle Outdated Show resolved Hide resolved
@kkafar
Copy link
Member

kkafar commented Nov 29, 2023

image

^ The graph indicates that, we do not need to specify this dependency explicitly at all -> as we do not use it directly & 2.5.1 is a direct dependency of fragment, which in turn we set explicitly to 1.3.6. So my conclusion is following: I do not understand why this change is needed & I believe right now it has no effect

@tboba
Copy link
Member Author

tboba commented Nov 29, 2023

@kkafar I believe that there's just a conflict between our library and other dependencies. The problem is that React Native 0.70.13 (in my case where I was testing it) had version 2.3.1 installed of lifecycle-viewmodel. I haven't divedeeped into the hierarchy that much, but maybe because we've updated material-related libraries currently we've got wrong version of lifecycle-viewmodel-ktx bundled and by specifying the version we're overriding the version that lies underneath one of the dependency?

@tboba tboba merged commit d4c16b8 into main Nov 29, 2023
4 checks passed
@tboba tboba deleted the @tboba/fix-screens-327 branch November 29, 2023 17:14
renovate bot referenced this pull request in valora-inc/wallet Jan 8, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[react-native-screens](https://togithub.com/software-mansion/react-native-screens)
| [`^3.27.0` ->
`^3.29.0`](https://renovatebot.com/diffs/npm/react-native-screens/3.27.0/3.29.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-screens/3.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-screens/3.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-screens/3.27.0/3.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-screens/3.27.0/3.29.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>software-mansion/react-native-screens
(react-native-screens)</summary>

###
[`v3.29.0`](https://togithub.com/software-mansion/react-native-screens/releases/tag/3.29.0)

[Compare
Source](https://togithub.com/software-mansion/react-native-screens/compare/3.28.0...3.29.0)

Minor release including fix for iOS that was accidentally omitted from
3.28.0. It should be now possible to present modal in outer stack, from
modal in nested stack (😄 )

#### What's Changed

#### 🐛 Bug fixes

- fix(iOS): select correct VC for nested modal presentation by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[https://github.com/software-mansion/react-native-screens/pull/1912](https://togithub.com/software-mansion/react-native-screens/pull/1912)

**Full Changelog**:
software-mansion/react-native-screens@3.28.0...3.29.0

###
[`v3.28.0`](https://togithub.com/software-mansion/react-native-screens/releases/tag/3.28.0)

[Compare
Source](https://togithub.com/software-mansion/react-native-screens/compare/3.27.0...3.28.0)

Minor release adding a support for **React Native 0.73**, adding new
iOS-like slide animation, fixing crashes with AVPlayer on iOS and
resolving build issues on Android.

#### What's Changed

#### 🐛 Bug fixes

- Update status bar & orientation in screen stack fragment by
[@&#8203;delphinebugner](https://togithub.com/delphinebugner) in
[https://github.com/software-mansion/react-native-screens/pull/1934](https://togithub.com/software-mansion/react-native-screens/pull/1934)
- Set stateWrapper in ScreenViewManager in Fabric by
[@&#8203;joemun](https://togithub.com/joemun) in
[https://github.com/software-mansion/react-native-screens/pull/1944](https://togithub.com/software-mansion/react-native-screens/pull/1944)
- Don't include AVPlayerView in `traverseForScrollView` method by
[@&#8203;tboba](https://togithub.com/tboba) in
[https://github.com/software-mansion/react-native-screens/pull/1969](https://togithub.com/software-mansion/react-native-screens/pull/1969)
- Fix error about duplicate class ViewModelLazy by
[@&#8203;tboba](https://togithub.com/tboba) in
[https://github.com/software-mansion/react-native-screens/pull/1977](https://togithub.com/software-mansion/react-native-screens/pull/1977)
- Move DelayedFreeze setImmediate into an effect by
[@&#8203;amadeus](https://togithub.com/amadeus) in
[https://github.com/software-mansion/react-native-screens/pull/1980](https://togithub.com/software-mansion/react-native-screens/pull/1980)

#### 👍 Improvements

- Add ios like slide animation by
[@&#8203;alexandrius](https://togithub.com/alexandrius) in
[https://github.com/software-mansion/react-native-screens/pull/1945](https://togithub.com/software-mansion/react-native-screens/pull/1945)

#### 🔢 Miscellaneous

- Support for RN 0.73 by [@&#8203;kkafar](https://togithub.com/kkafar)
in
[https://github.com/software-mansion/react-native-screens/pull/1956](https://togithub.com/software-mansion/react-native-screens/pull/1956)
- Use JDK 17 for CI builds as required for RN 0.73 by
[@&#8203;kkafar](https://togithub.com/kkafar) in
[https://github.com/software-mansion/react-native-screens/pull/1957](https://togithub.com/software-mansion/react-native-screens/pull/1957)
- Update Podfile.lock files in example projects by
[@&#8203;tboba](https://togithub.com/tboba) in
[https://github.com/software-mansion/react-native-screens/pull/1979](https://togithub.com/software-mansion/react-native-screens/pull/1979)

#### New Contributors

- [@&#8203;delphinebugner](https://togithub.com/delphinebugner) made
their first contribution in
[https://github.com/software-mansion/react-native-screens/pull/1934](https://togithub.com/software-mansion/react-native-screens/pull/1934)
- [@&#8203;joemun](https://togithub.com/joemun) made their first
contribution in
[https://github.com/software-mansion/react-native-screens/pull/1944](https://togithub.com/software-mansion/react-native-screens/pull/1944)
- [@&#8203;alexandrius](https://togithub.com/alexandrius) made their
first contribution in
[https://github.com/software-mansion/react-native-screens/pull/1945](https://togithub.com/software-mansion/react-native-screens/pull/1945)
- [@&#8203;amadeus](https://togithub.com/amadeus) made their first
contribution in
[https://github.com/software-mansion/react-native-screens/pull/1980](https://togithub.com/software-mansion/react-native-screens/pull/1980)

**Full Changelog**:
software-mansion/react-native-screens@3.27.0...3.28.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 5pm,every weekend" in timezone
America/Los_Angeles, Automerge - "after 5pm,every weekend" in timezone
America/Los_Angeles.

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/valora-inc/wallet).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: valora-bot <valorabot@valoraapp.com>
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…-mansion#1977)

## Description

Users are reporting that they are receiving error while building their
project with react-native-screens 3.27.0:

```
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.2.0-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0) and lifecycle-viewmodel-2.5.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.0)
```

This error is fairly easy to fix and is related to the wrong imports of
dependencies in gradle.
Closes software-mansion#1947.

## Changes

- Added import for `lifecycle-viewmodel` and `lifecycle-viewmodel-ktx`
(these two imports are necessary, as `lifecycle-viewmodel` evokes error
for `lifecycle-viewmodel-ktx`.

## Checklist

- [ ] Ensured that CI passes

---------

Co-authored-by: Kacper Kafara <kacperkafara@gmail.com>
Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android build failure 3.27.0
2 participants