Your project has set `android.useAndroidX=true` but configuration `debugRuntimeClasspath` still contains legacy support libraries

Viewed 10706

I am getting an warning in android studio when I run my app. the warning is- Your project has set android.useAndroidX=true, but configuration debugRuntimeClasspath still contains legacy support libraries, which may cause runtime issues. And a error- Manifest merger failed with multiple errors, see logs I checked my manifest file and there is no error in my manifest file. I tried debugging the app but it still doesn't fix. I am getting this after updating android studio from android studio arctic fox to android studio bumble bee which is recently released. I updated the gradle version tried cleaning project, invalidating caches but nothing worked. I increased the memory heap size and enabled multidex but still it is not fixed. Please help me out.

4 Answers
  1. Comment this line in setting.gradle
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  1. Add this in build.gradle(Project:...) :
allprojects {
   repositories {
       google()
       jcenter()
       maven { url "https://jitpack.io" }
   }
}
  1. Add in gradle.properties:
android.enableJetifier=true
android.useAndroidX=true

Add these in gradle.properties:

android.enableJetifier=true
android.useAndroidX=true

Sync your gradle and Run the app. It worked fine for me and I didn't have to do the changes in setting.gradle and build.gradle (Project level) or any other files.

My solution is simialar to @JJ Smith one. But I didn't do anything to build.gradle file. So:

  1. Comment this line in setting.gradle:
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  1. Make sure you have these 2 lines in gradle.properties (if not add them or change them to true):
android.enableJetifier=true
android.useAndroidX=true
  1. Sync gradle

I DID NOT change the build.gradle(at project level) file. I report it here just for the sake of completeness:

buildscript {
    repositories {
        google()
    }
    dependencies {
        //...
    }
}


plugins {
    id 'com.android.application' version '7.2.0' apply false
    id 'com.android.library' version '7.2.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Check if you the following dependency:

implementation 'com.android.support:multidex:1.0.3'

If you have it, just remove it. It worked for me.

Related