java - 如何解决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
}
我做了同样的事情,但结果还是一样。我完全受够了。尝试了每一个解决方案。重建项目但为零。我看到了一些最近的问题,它们都是一样的,但我的问题没有解决,所以这不是一个重复的问题。我什么都试过了。
解决方案
所有遇到这些错误的人。我通过在 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 !!!它突然编译了我的代码。
推荐阅读
- json - 如何在 JSON 文件中设置新日期
- javascript - 无法通过 rtcpeerconnection 获取本地 IP 地址
- matplotlib - 在 matplotlib 图的底部添加一个属性文本框
- java - 在 Akka 流中将 JSON 作为单个实体处理,而不是对其进行迭代
- swift - Core Data + SwiftUI:无法将“Bool”类型的值转换为预期的参数类型“Binding”
' - python - python输出对象不可迭代
- php - Laravel 插入和更新三个表之间的多对多关系
- signals - Octave 中的信号分析
- google-coral - Coral Edge TPU 开发板是否支持 AT+STA 双模
- javascript - 全日历多日期事件显示短一天