无法解析':app @ debug/compileClasspath'的依赖关系:无法转换工件'lifecycle-viewmodel.aar
我使用最新的Android Studio 3.5版本(Android Gradle插件3.5.0).当我尝试编译时,我收到此错误:
I use latest Android Studio 3.5 version (Android Gradle plugin 3.5.0). When I try to compile I receive this error:
错误:无法解析':app @ debug/compileClasspath'的依赖项: 无法转换工件'lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.1.0)'来匹配属性 {artifactType = jar}.显示详细信息受影响的模块:app
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform artifact 'lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.1.0)' to match attributes {artifactType=jar}. Show Details Affected Modules: app
错误:无法解决以下项的依赖性 ':app @ debugAndroidTest/compileClasspath':无法转换工件 'lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.1.0)'来匹配属性 {artifactType = jar}.显示详细信息受影响的模块:app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform artifact 'lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.1.0)' to match attributes {artifactType=jar}. Show Details Affected Modules: app
错误:无法解决以下项的依赖性 ':app @ debugUnitTest/compileClasspath':无法转换工件 'lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.1.0)'来匹配属性 {artifactType = jar}.显示详细信息受影响的模块:app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform artifact 'lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.1.0)' to match attributes {artifactType=jar}. Show Details Affected Modules: app
能否请您共享build.gradle文件?虽然我不确定,但可能可行
Can you please share your build.gradle file ? Although I am not sure but it may works
解决方案1:转到文件".单击使缓存无效/重新启动".再次单击Invalidate Cache/Restart
Solution 1: Go to "File". Click on Invalidate Cache/ Restart. Again click on Invalidate Cache / Restart
解决方案2:更改
应用插件:"com.android.application" 到 应用插件:"com.android.library"
apply plugin: 'com.android.application' to apply plugin: 'com.android.library'
解决方案3: 逐一注释依赖项,然后尝试运行
Solution 3: comment out one by one in dependencies and try to run