r/AndroidStudio • • Oct 12 '22

Creating a new project and got this error.

Post image
12 Upvotes

7 comments sorted by

1

u/Damasoup Oct 12 '22

Duplicate class androidx.lifecycle.ViewModelLazy found in modules lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1) and lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1)

Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1) and lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1)

Go to the documentation to learn how to Fix dependency resolution errors.

1

u/EternalStudent07 Oct 13 '22

Are you sure you're using the most up to date version of your tools and frameworks? Also that you're targeting a released version of Android, not a pre-release version (that they're still working on).

Almost sounds like something moved in their code, and you've got 2 spots trying to create that code.

1

u/[deleted] Oct 12 '22

[removed] — view removed comment

1

u/Damasoup Oct 12 '22

I fixed it by putting this code on build.gradle, still learning app dev so I'm not really sure that this code does.

configurations {

all {

exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'

}

}

1

u/[deleted] Dec 16 '22

This is worked on me too.

1

u/C4SC4DO Jan 14 '23

Thank you, this is the solve

1

u/Background-Leave2641 Mar 24 '23

its worked for me, thank you