1

I use latest Android Studio 3.5 version (Android Gradle plugin 3.5.0). When I try to compile I receive this error:

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

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

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

Jonik
  • 80,077
  • 70
  • 264
  • 372
Asad
  • 13
  • 1
  • 5

3 Answers3

2

Can you please share your build.gradle file ? Although I am not sure but it may works

Solution 1: Go to "File". Click on Invalidate Cache/ Restart. Again click on Invalidate Cache / Restart

Solution 2: Change

apply plugin: 'com.android.application' to apply plugin: 'com.android.library'

Solution 3: comment out one by one in dependencies and try to run

Suman Kumar Dash
  • 681
  • 5
  • 19
  • Not Working in my case – Asad Sep 10 '19 at 07:19
  • apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.demo" minSdkVersion 27 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } – Asad Sep 10 '19 at 07:19
  • // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } – Asad Sep 10 '19 at 07:20
  • comment out one by one in dependencies and try to run. – Suman Kumar Dash Sep 10 '19 at 07:30
  • 1
    thank it's working i comment implementation 'androidx.appcompat:appcompat:1.1.0' this dependency – Asad Sep 10 '19 at 09:29
  • Welcome. Its my pleasure to help you. Please accept the solution by click accept mark. When the same problem will come everyone can see this solution. – Suman Kumar Dash Sep 11 '19 at 00:13
  • thanks! big help. Im having this error: (Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform artifact 'annotation-experimental.aar) I tried to comment out this: implementation 'androidx.core:core-ktx:1.9.0' and it works okay now. :) – nit21 Sep 20 '22 at 12:11
0

Just rename your library or Copy your library name from refactor and paste it in build.gradle.

Siri
  • 701
  • 1
  • 6
  • 27
0

In my case, updating gradle.properties worked.

Before:

org.gradle.jvmargs=-Xmx1536M

After:

org.gradle.jvmargs=-Xmx4096M
Mugur
  • 1,019
  • 9
  • 21