From 6574add105449582a7d0838075001b63e632c993 Mon Sep 17 00:00:00 2001 From: Tymoteusz Boba Date: Wed, 29 Nov 2023 18:14:31 +0100 Subject: [PATCH] fix(Android): Fix error about duplicate class ViewModelLazy (#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 #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 Co-authored-by: Kacper Kafara --- android/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index 6fc7919f60..47511890e1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -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") + } + } }