Skip to content

Commit

Permalink
fix(Android): Fix error about duplicate class ViewModelLazy (#1977)
Browse files Browse the repository at this point in the history
## 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

---------

Co-authored-by: Kacper Kafara <[email protected]>
Co-authored-by: Kacper Kafara <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2023
1 parent 2756734 commit d4c16b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,10 @@ dependencies {
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.android.material:material:1.9.0'
implementation "androidx.core:core-ktx:1.8.0"

constraints {
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1") {
because("on older React Native versions this dependency conflicts with react-native-screens")
}
}
}

0 comments on commit d4c16b8

Please sign in to comment.