首页 > 解决方案 > 如何解决android studio中依赖项的AAR元数据中指定的minCompileSdk(31)

问题描述

我目前正在 android studio 中开发一个 java 应用程序项目。一切正常,但在我遇到一些奇怪的问题之前 2-3 天。google我什至搜索了很多,stackOverFlow但没有得到任何可行的解决方案。

我正在使用compilesdk 30,它给了我以下错误。

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.

我搜索并将其更改compilesdk 30为 31。之后,我在清单文件中收到以下错误。

Error: android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. DataFinderStudio.app main manifest (this file)

Error: android:exported needs to be explicitly specified for <activity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. DataFinderStudio.app main manifest (this file)

这是两个错误。放入意图过滤器时已解决一个问题,android:exported但第二个仍然存在。我把所有地方都出口了,但结果是一样的。

如果我将以下代码放入依赖项 gradle 中,我再次进行了搜索并获得了最新的解决方案,那么它将得到解决。

def work_version = "2.6.0"
    // Force WorkManager 2.6.0 for transitive dependency
    implementation("androidx.work:work-runtime-ktx:$work_version") {
        force = true
    }

我做了同样的事情,但结果还是一样。我完全受够了。尝试了每一个解决方案。重建项目但为零。我看到了一些最近的问题,它们都是一样的,但我的问题没有解决,所以这不是一个重复的问题。我什么都试过了。

标签: javaandroid

解决方案


所有遇到这些错误的人。我通过在 defaultconfig 下的应用级 build.gradle 文件中添加以下代码行来解决此错误。

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

我已经粘贴了这work-runtine行代码,但@soujanya 又给了我一行代码,即core-ktx:1.6.0. 我在下面粘贴了相同的内容,work-runtime然后BOOOOM !!!它突然编译了我的代码。


推荐阅读