记录AS Duplicate class依赖问题之一

运行报错信息:

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)

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

遇到这个问题 莫名其妙  我只是升级了AS版本 ,升级到 

Android Studio Electric Eel | 2022.1.1

Build #AI-221.6008.13.2211.9477386, built on January 11, 2023

 再次运行就报了这个错

我的解决方式是直接加入:

    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'

报错就解决了,也不晓得为什么,我发现直接新开一个项目跟我现在的项目引入lifecycle包 基本一样

 

你可能感兴趣的:(android,基础,android,android,studio,ide)