Android - 应用程序未运行。错误 : The minCompileSdk specified in a dependency's AAR metadata is greater than this module's compileSdkVersion

标签 android android-studio gradle build

<分区>

一周前该应用程序运行良好,但突然(没有更新任何内容)该应用程序无法运行。

当我尝试运行应用程序时出现此错误

The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30). Dependency: androidx.work:work-runtime:2.7.0-beta01. AAR metadata file: /home/kishan/.gradle/caches/transforms-2/files-2.1/af85edd7f0482dfc2b2e0c9a0519784e/work-runtime-2.7.0-beta01/META-INF/com/android/build/gradle/aar-metadata.properties.

这是相同的屏幕截图:

enter image description here

从我的应用级 gradle 文件中,我可以看到我拥有

compileSdkVersion 30targetSdkVersion 30

不确定是什么导致了这个问题。

如有任何帮助,我们将不胜感激。 谢谢!

最佳答案

好的,所以我终于解决了这个问题。

问题是因为依赖 androidx.work:work-runtime 但我想首先提到的是,我没有直接在我的项目中使用该依赖项(未添加到我的应用程序级 gradle 中),可能是其他一些依赖项在内部使用了它。

所以我所做的就是通过添加这个来强行降级它的版本

configurations.all {
        resolutionStrategy { force 'androidx.work:work-runtime:2.6.0' }
    }

里面

android {
 defaultConfig {
   //here
 }
}

它解决了我的问题。

关于Android - 应用程序未运行。错误 : The minCompileSdk specified in a dependency's AAR metadata is greater than this module's compileSdkVersion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69054222/

相关文章:

Android Studio 总是重建应用程序

java - 任务 ':compileDebugJavaWithJavac 执行失败

android - NSString 类型的 JSON 值无法转换为 ABI38_0_0YGValue

java - 无法仅在控制台中启动androidstudio

java.lang.ClassNotFoundException : org. sqlite.JDBC Androidstudio Java 模块

gradle - 如何仅在gradle中列出主项目的所有任务?

android - 如何在VideoView中播放视频?

java - 编译在 Android Studio 中使用的 GitHub 项目

android - 造型 OssLicensesMenuActivity

java - 使用 Gson 将 JSON 字符串转换为对象数组