While migrating an Android project from the support libraries to use the
AndroidX libraries, I encountered the following errors regarding "
duplicate class android.support.v4.app xxxx found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)"; even though all the
Java/Kotlin/XML source code files have been replaced with the
AndroidX versions and the old support libraries have been removed from the app's
build.gradle file.
The screenshot below illustrates the error.
The solution I found was to set project wide gradle properties.
- In Android Studio, open up the project's gradle.properties file.
- Insert the following two lines:
android.enableJetifier=true
android.useAndroidX=true

- Save the file, select Build | Clean Project. Then select recompile again.
The duplicate classes error messages no longer appear.|
1 comment:
Thanks :D
Post a Comment