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
  • 77,494
  • 68
  • 254
  • 365
Asad
  • 13
  • 1
  • 5

3 Answers3

1

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
  • 605
  • 4
  • 18
  • 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
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
  • 869
  • 8
  • 20