react-native 2022.11.4号开始打包失败问题The minCompileSdk (31) specified in a is greater than this module‘s

react-native 2022.11.4号开始打包失败问题

  • 错误信息如下
* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.appcompat:appcompat:1.4.1.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/59edff95b28aac4602de9bd7b095e476/appcompat-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.appcompat:appcompat-resources:1.4.1.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/5eca708b3b532e9daeb3d43f167c7531/jetified-appcompat-resources-1.4.1/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.emoji2:emoji2-views-helper:1.0.0.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/ca4a76d2c3f18d70820ed26335d69838/jetified-emoji2-views-helper-1.0.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.emoji2:emoji2:1.0.0.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/9eefc2161c1faa4e75c6e993b8f3ebe8/jetified-emoji2-1.0.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.lifecycle:lifecycle-process:2.4.0.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/d546129225562ffaf8f872a77e9c25bc/jetified-lifecycle-process-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.tracing:tracing:1.1.0.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/cf730d8026c953ae8833984b6e09027f/jetified-tracing-1.1.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.core:core:1.7.0.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/96f4429105cb0d56c8d0240cb95629c0/core-1.7.0/META-INF/com/android/build/gradle/aar-metadata.properties.
   > A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
      > 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-29).
        Dependency: androidx.lifecycle:lifecycle-runtime:2.4.0.
        AAR metadata file: /Users/windows/.gradle/caches/transforms-2/files-2.1/48b27669722b644e756b061254d5d2c9/lifecycle-runtime-2.4.0/META-INF/com/android/build/gradle/aar-metadata.properties.

原因:

官方发布 0.71-rc.0 版本,导致 0.71以下版本编译报错

解决方案

0.63以上升级到当前版本的最新小版本:

0.70.5
0.69.7
0.68.5
0.67.5
0.66.5
0.65.3
0.64.4
0.63.5

0.63 以下编辑 android/build.gralde 文件,添加如下代码

+ def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
allprojects {
+    configurations.all {
+        resolutionStrategy {
+            // Remove this override in 0.65+, as a proper fix is included in react-native itself.
+            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
+        }
+    }
}

原文: https://blog.csdn.net/qq_38545425/article/details/127792793
参考:https://github.com/reactnativecn/react-native-website/issues/660

你可能感兴趣的:(android,react,native,javascript)