I faced the same situation while implementing the maps api in my application.
I solved it by adding the following code in AndroidManifest.xml and Gradle.properties file.
In AndroidMainfest.xml
added this code
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
tools:replace="android:appComponentFactory"
In gradle.properties added this code
android.useAndroidX=true
android.enableJetifier=true
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…