Skip to content

Commit

Permalink
fix(Android): Fix error about duplicate class ViewModelLazy (software…
Browse files Browse the repository at this point in the history
…-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>
  • Loading branch information
3 people authored and ja1ns committed Oct 9, 2024
1 parent c983f01 commit 6574add
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 6574add

Please sign in to comment.