【问题标题】:After update lifecyle to version 2.4.0 Make build error AAR metadata file: **/aar-metadata.properties将生命周期更新到版本 2.4.0 后生成错误 AAR 元数据文件:**/aar-metadata.properties
【发布时间】:2021-11-13 07:42:54
【问题描述】:

将生命周期版本更新到 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' }
    }

【问题讨论】:

    标签: android activity-lifecycle


    【解决方案1】:

    将 compileSdk 更改为 31 和 targetSdk 31

    如果使用 AGP 7.* 或更高版本

    android {
        compileSdk 30
    
        defaultConfig {
            ...
            targetSdk 30
            ...
        }
        ...
    }
    

    如果使用低于 7 的 AGP

    android {
        compileSdkVersion 30
       
        defaultConfig {
            ...
            targetSdkVersion 30
            ...
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-05-03
      • 2018-06-22
      • 2022-07-24
      • 2017-05-04
      • 2014-07-11
      • 1970-01-01
      • 2017-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多