无法在 android studio 中编译依赖项

Dependencies cannot be compiled in android studio

implementation 'com.karumi:dexter:6.0.0' 添加到 build.gradle 文件时,在执行 appcompat 时第 24 行显示错误:implementation 'com.android.support:appcompat-v7:26.1.0'

its the build.gradle(Module:app)

Error in Gradle

您尝试使用的库正在使用 AndroidX 库,而您在项目中使用的是 Andeoid 支持库。要么将您的项目迁移到 androidx,要么是使用 android 支持库的旧版本库。

  • 从你的gradle错误信息来看,你使用的是andorid早期的工程结构库
  • 您正在尝试实施 implementation 'com.karumi:dexter:6.0.0' 库,该库使用 androidx 支持库结构。

因此,您会收到该错误,因为您不能同时使用这两种结构,因为它们的制作和组织方式完全不同。

解法:

如果您真的想使用那个库,请切换到 androidx 库结构。

参考 Google Android 的官方文档从 android -

迁移到 andoirdx

Google Developers Documentation

您应该迁移您的项目 AppCopact to AndroidX。要将项目 AppCompact 迁移到 Androidx Go Refactor -> Migrate to Androidx,然后勾选备份项目并迁移。迁移后 com.karumi:dexter:6.0.0 库将完美运行。