
Dependencies using groupId com.android.support and androidx.* can not be combined but found com.android.support:exifinterface:27.1.0 and androidx.appcompat:appcompat:1.6.1 incompatible dependencies

Dependencies using groupId com.android.support and androidx.* can not be combined but found com.android.support:exifinterface:27.1.0 and androidx.appcompat:appcompat:1.6.1 incompatible dependencies
暮雪(。・ω・。) 上午好☀️☀️☀️️
本答案参考ChatGPT-3.5
这个问题是由于在Android项目中,使用了 com.android.support 和 androidx.* 这两种不兼容的依赖关系导致的。具体来说,报错中显示了 com.android.support:exifinterface:27.1.0 和 androidx.appcompat:appcompat:1.6.1 这两个依赖之间有冲突。
解决方案:
更新 com.android.support 依赖为 androidx.* 依赖:将项目中所有使用 com.android.support 依赖的地方,都改为对应的 androidx.* 依赖。比如,将 com.android.support:exifinterface:27.1.0 改为 androidx.exifinterface:exifinterface:1.1.0。
检查依赖冲突:使用 Gradle 的命令 gradlew -q dependencies 查看项目中所有的依赖关系,找出冲突的依赖并进行解决。
使用 dependencyResolutionRules:在项目的 build.gradle 文件中,使用 dependencyResolutionRules 属性来处理依赖冲突。具体步骤如下:
configurations.all {
resolutionStrategy {
force "com.android.support:exifinterface:27.1.0"
force "androidx.appcompat:appcompat:1.6.1"
}
}
排除冲突依赖:在项目的 build.gradle 文件中,使用 exclude 属性来排除冲突的依赖。具体步骤如下:
implementation('com.android.support:exifinterface:27.1.0') {
exclude group: 'androidx.appcompat'
}
需要注意的是,解决依赖冲突可能还涉及到其他依赖关系,需要根据具体情况进行调整。在进行任何依赖更改之前,最好先备份项目或进行版本控制,以防万一。