I have tried many solutions on this website but still, the problem is not solved. The issue is due to Android X library. When I added Android X, this issue was resolved but
I added below lines inside <application>
tag
tools:replace="android:appComponentFactory"
android:appComponentFactory="android.support.v4.app.CoreComponentFactory"
below lines inside gradle.properties file
android.useAndroidX=true
android.enableJetifier=true
Rebuild your project.
you need just add this code in gradle.properties file
android.useAndroidX=true
android.enableJetifier=true
It often happened because you used Androidx libraries and support libraries at the same time. Some 3rd-party libraries may contain support libraries and other 3rd-party libraries may contain Androidx libraries, this can also lead this problem. If you have gradle environment in you PC, try "gradlew :app:dependencies" command in the terminal of Android Studio, this command will list all libraries including 3rd-party libraries of your project, and see which library or framework used Androidx libraries and which not. Then try to upgrade old libraries used support libraries, and this problem should disappear.