google-developer-training / android-basics-kotlin-cupcake-app

Apache License 2.0
103 stars 163 forks source link

Android Basics: Shared ViewModel #99

Closed Napharcos closed 1 year ago

Napharcos commented 1 year ago

URL of codelab

https://developer.android.com/codelabs/basic-android-kotlin-training-shared-viewmodel?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-kotlin-unit-3-pathway-4%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-training-shared-viewmodel#9

In which task and step of the codelab can this issue be found?

Describe the problem

I got error after running my project.

I get the same error when running the solution code:

https://github.com/google-developer-training/android-basics-kotlin-cupcake-app/tree/viewmodel

Steps to reproduce?

  1. Go to...

download solution code

  1. Click on...

run

  1. See error...

"Execution failed for task ':app:checkDebugDuplicateClasses'.

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.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0) Duplicate class androidx.lifecycle.ViewModelProviderKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0) Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)

Versions Android Studio version:

Flamingo, 2022.2.1

API version of the emulator:

33

Additional information Include screenshots if they would be useful in clarifying the problem.

Ninidze1 commented 1 year ago

check if helps: https://github.com/google-developer-training/android-basics-kotlin-cupcake-app/pull/100

Napharcos commented 1 year ago

https://github.com/google-developer-training/android-basics-kotlin-cupcake-app/pull/100

This fixes the error. Thank you very much.