Duplicate classes from androidx and com.android.support Duplicate classes from androidx and com.android.support android android

Duplicate classes from androidx and com.android.support


Add these lines to gradle.properties:

android.useAndroidX=trueandroid.enableJetifier=true

If gradle.properties is absent, create the file in the root directory of your project.

It looks like you have some support relics anywhere in your dependencies, maybe from a lib? To investigate and see the dependencies tree, please run:

./gradlew :yourApp:dependencies

and then you see from where it comes.


In your app build.gradle you are using a mix of old support library and new support library artifacts. Remove one of them from your build.gradle to resolve this issue.

Old artifact: com.android.support:support-compat

Corresponding new artifact: androidx.core:core:1.0.0

See this page for more information on migrating to AndroidX.


Like others says, the solution is to migrating to AndroidX, it works for me. However, it isn´t an easy way and it requires a bit of pacience... These are the steps that I did:

  • First, is very important that you do all this changes in a different branch or you make a backup of your project.

  • You need to have the Android Gradle Plugin Version 3.5.1. So, in build.gradle set:

dependencies {    classpath 'com.android.tools.build:gradle:3.5.1'}
  • Migrate to AndroidX using Android Studio Tool : Refactor --> Migrate to AndroidX...
  • When it finishes, it has done all pertinents modification, but posibly you can´t deploy the project correctly because you find any errors. These are the problems that I found and the solutions:

  • If you use Kotlin, in build.gradle set:

buildscript {    ext.kotlin_version = '1.3.10'}

and

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
  • If you use destination method, add "file" parameter: destination file("$reportsDir/checkstyle/checkstyle.xml")
  • If you use Butterknife, use 10.0.0 version
  • Finally, Build --> Clean Project and Build --> Rebuild Project