android - 将生命周期更新到版本 2.4.0 后生成错误 AAR 元数据文件:**/aar-metadata.properties
问题描述
将生命周期版本更新到 2.4.0 后,我无法构建我的应用程序,错误代码是:
One or more issues found when checking AAR metadata values:
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.lifecycle:lifecycle-viewmodel-ktx:2.4.0.
AAR metadata file: **/transformed/jetified-lifecycle-viewmodel-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
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.lifecycle:lifecycle-livedata-ktx:2.4.0.
AAR metadata file: **/transformed/jetified-lifecycle-livedata-ktx-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
添加了此代码,但对我不起作用
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.6.0' }
}
解决方案
将 compileSdk 更改为 31 和 targetSdk 31
如果使用 AGP 7.* 或更高版本
android {
compileSdk 30
defaultConfig {
...
targetSdk 30
...
}
...
}
如果使用 AGP 低于 7
android {
compileSdkVersion 30
defaultConfig {
...
targetSdkVersion 30
...
}
}
推荐阅读
- .net - Powershell Get-Date -Day(新年)
- java - Intellij JavaFX - 在 jar 中找不到资源目录
- json - 从 vue 中的 axios 调用访问 json 数据
- javascript - 如何在 React-Native 中创建 Action-Sheet/Bottom-Sheet 样式的抽屉?
- powershell - PowerShell 脚本没有像我想要的那样复制
- allocator - 寻找 Dobb 博士 2003/04/01 文章中提供的完整 SharedAllocator 源
- java - 从不同窗口输入后的Java更新对象
- node.js - Node JS 适合作为即时消息服务吗?MongoDB适合作为数据库吗?
- python - 为什么内部“for循环”在代码中不起作用?
- php - 发布网站后如何确定用户角色?