一、修改项目gradle.properties文件:
#true表示当前项目启用AndroidX
android.useAndroidX=false
#true表示将依赖包也迁移到AndroidX
android.enableJetifier=false
二、在build.gradle去掉androidx的引用,改为supportv7的引用
implementation 'com.android.support:appcompat-v7:28.0.0'
三、sync代码之后如果还有androidx包引用冲突的问题,可在build.gradle如下设置,完全去掉androidx的依赖:
android {
configurations {
all*.exclude group: 'androidx.arch.core'
all*.exclude group: 'androidx.lifecycle'
all*.exclude group: 'androidx.paging'
all*.exclude group: 'androidx.room'
all*.exclude group: 'androidx.sqlite'
all*.exclude group: 'androidx.constraintlayout'
all*.exclude group: 'androidx.vectordrawable'
all*.exclude group: 'androidx.appcompat'
all*.exclude group: 'androidx.asynclayoutinflater'
all*.exclude group: 'androidx.cardview'
all*.exclude group: 'androidx.car'
all*.exclude group: 'androidx.collection'
all*.exclude group: 'androidx.coordinatorlayout'
all*.exclude group: 'androidx.cursoradapter'
all*.exclude group: 'androidx.browser'
all*.exclude group: 'androidx.customview'
all*.exclude group: 'com.google.android.material'
all*.exclude group: 'androidx.documentfile'
all*.exclude group: 'androidx.drawerlayout'
all*.exclude group: 'androidx.exifinterface'
all*.exclude group: 'androidx.gridlayout'
all*.exclude group: 'androidx.heifwriter'
all*.exclude group: 'androidx.interpolator'
all*.exclude group: 'androidx.leanback'
all*.exclude group: 'androidx.loader'
all*.exclude group: 'androidx.localbroadcastmanager'
all*.exclude group: 'androidx.media2'
all*.exclude group: 'androidx.mediarouter'
all*.exclude group: 'androidx.multidex'
all*.exclude group: 'androidx.palette'
all*.exclude group: 'androidx.percentlayout'
all*.exclude group: 'androidx.leanback'
all*.exclude group: 'androidx.legacy'
all*.exclude group: 'androidx.preference'
all*.exclude group: 'androidx.print'
all*.exclude group: 'androidx.recommendation'
all*.exclude group: 'androidx.recyclerview'
all*.exclude group: 'androidx.slice'
all*.exclude group: 'androidx.slidingpanelayout'
all*.exclude group: 'androidx.annotation'
all*.exclude group: 'androidx.core'
all*.exclude group: 'androidx.contentpager'
all*.exclude group: 'androidx.legacy'
all*.exclude group: 'androidx.dynamicanimation'
all*.exclude group: 'androidx.emoji'
all*.exclude group: 'androidx.fragment'
all*.exclude group: 'androidx.media'
all*.exclude group: 'androidx.tvprovider'
all*.exclude group: 'androidx.vectordrawable'
all*.exclude group: 'androidx.swiperefreshlayout'
all*.exclude group: 'androidx.textclassifier'
all*.exclude group: 'androidx.transition'
all*.exclude group: 'androidx.versionedparcelable'
all*.exclude group: 'androidx.viewpager'
all*.exclude group: 'androidx.wear'
all*.exclude group: 'androidx.webkit'
}
}