gpt4 book ai didi

javascript - 运行时出错 `react-native run-android`

转载 作者:行者123 更新时间:2023-12-04 23:35:41 25 4
gpt4 key购买 nike

在运行我的 react native 代码时 react-native run-android低于错误。它工作正常。但是在从 git 和 npm ci 获得新的拉动之后并且在我运行之后出现此错误。

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> The minCompileSdk (30) 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-alpha01.
AAR metadata file: C:\Users\gauraab\.gradle\caches\transforms-2\files-2.1\9e02d64f5889006a671d0a7165c73e72\core-1.7.0-alpha01\META-INF\com\android\build\gradle\aar-metadata.properties.

最佳答案

正如一些人所提到的,问题在于 RN 构建自动“升级”到 androidx.core:core:1.7.0-alpha01,这取决于 SDK 版本 30。
修复
修复只是在 build.gradle 中通过 androidXCore 指定 android 核心版本

buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 23
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
kotlin_version = "1.5.0"
androidXCore = "1.5.0"
}
我是怎么想出来的
弄清楚这一点很痛苦。我 grepped 的 gradle 文件会像这样自动升级包
find . -name '*.gradle' -exec grep -H "\.+" {} \;
并在 node_modules/@react-native-community/netinfo/android/build.gradle 中找到以下 fragment
def androidXCore = getExtOrInitialValue('androidXCore', null)
if (supportLibVersion && androidXVersion == null && androidXCore == null) {
implementation "com.android.support:appcompat-v7:$supportLibVersion"
} else {
def defaultAndroidXVersion = "1.+"
if (androidXCore == null) {
androidXCore = androidXVersion == null ? defaultAndroidXVersion : androidXVersion
}
implementation "androidx.core:core:$androidXCore"
}
}

关于javascript - 运行时出错 `react-native run-android`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68207334/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com