当我尝试运行 npx react-native run-android 时,任务:app:mergeDebugAssets 失败

2024-04-06

我正在使用 vscode 和物理 Android 设备在 React-Native 上开发 Android 应用程序,在尝试使用 npx React-Native Run-Android 进行构建时,它不断显示以下错误。

Task :app:mergeDebugAssets FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
38 actionable tasks: 38 executed
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve org.webkit:android-jsc:+.
     Required by:
         project :app
      > Failed to list versions for org.webkit:android-jsc.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 1s

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 app:installDebug -PreactNativeDevServerPort=8081
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve org.webkit:android-jsc:+.
     Required by:
         project :app
      > Failed to list versions for org.webkit:android-jsc.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 1s

    at makeError (/home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
    at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (/home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/home/akaranath/Desktop/krop_delivery_cs/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)

当我开始一个新项目时,这种情况经常发生,并且通常必须完全开始一个新项目才能解决此错误。

这些是我尝试解决该错误的一些方法。

  1. 尝试了 ./gradlew clean 并再次尝试构建应用程序。
  2. 在 app/build.gradle 中启用 multiDexEnabled
  3. 我正在使用物理 Android 设备来运行该应用程序。我尝试卸载该应用程序并尝试再次构建该应用程序。
  4. 删除了node_modules,清除了npm缓存并尝试再次安装所有node_modules。

有谁知道如何解决这一问题?

以下是有关该项目的一些详细信息

package.json 依赖项

"dependencies": {
    "react": "17.0.1",
    "react-native": "0.64.2",
    "@react-native-async-storage/async-storage": "^1.15.5",
    "@react-native-firebase/app": "^13.0.1",
    "@react-native-firebase/auth": "^13.0.1",
    "@react-native-firebase/firestore": "^13.0.1",
    "@react-navigation/bottom-tabs": "^6.0.4",
    "@react-navigation/native": "^6.0.4",
    "@react-navigation/stack": "^6.0.4",
    "moment": "^2.29.1",
    "react-native-bootsplash": "^3.2.6",
    "react-native-geolocation-service": "^5.3.0-beta.3",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-paper": "^4.9.2",
    "react-native-push-notification": "^8.1.1",
    "react-native-safe-area-context": "^3.3.0",
    "react-native-screens": "^3.5.0",
    "react-native-vector-icons": "^8.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "17.0.1"
  },

android/build.gradle 信息

buildscript {
    ext {
        buildToolsVersion = "29.0.3"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
        ndkVersion = "20.1.5948944"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.1.0")
        classpath 'com.google.gms:google-services:4.3.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

./gradlew build --warning-mode all 的输出

> Configure project :react-native-firebase_app
:react-native-firebase_app package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:firebase.bom using default value: 29.0.2
:react-native-firebase_app:play.play-services-auth using default value: 20.0.0
:react-native-firebase_app package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_app:version set from package.json: 13.1.1 (13,1,1 - 13001001)
:react-native-firebase_app:android.compileSdk using custom value: 29
:react-native-firebase_app:android.targetSdk using custom value: 29
:react-native-firebase_app:android.minSdk using custom value: 21
:react-native-firebase_app:reactNativeAndroidDir /home/akaranath/Desktop/krop_delivery_cs/node_modules/react-native/android

> Configure project :react-native-firebase_auth
:react-native-firebase_auth package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/auth/package.json
:react-native-firebase_app package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_auth:firebase.bom using default value: 29.0.2
:react-native-firebase_auth package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/auth/package.json
:react-native-firebase_auth:version set from package.json: 13.1.1 (13,1,1 - 13001001)
:react-native-firebase_auth:android.compileSdk using custom value: 29
:react-native-firebase_auth:android.targetSdk using custom value: 29
:react-native-firebase_auth:android.minSdk using custom value: 21
:react-native-firebase_auth:reactNativeAndroidDir /home/akaranath/Desktop/krop_delivery_cs/node_modules/react-native/android

> Configure project :react-native-firebase_firestore
:react-native-firebase_firestore package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/firestore/package.json
:react-native-firebase_app package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_firestore:firebase.bom using default value: 29.0.2
:react-native-firebase_firestore package.json found at /home/akaranath/Desktop/krop_delivery_cs/node_modules/@react-native-firebase/firestore/package.json
:react-native-firebase_firestore:version set from package.json: 13.1.1 (13,1,1 - 13001001)
:react-native-firebase_firestore:android.compileSdk using custom value: 29
:react-native-firebase_firestore:android.targetSdk using custom value: 29
:react-native-firebase_firestore:android.minSdk using custom value: 21
:react-native-firebase_firestore:reactNativeAndroidDir /home/akaranath/Desktop/krop_delivery_cs/node_modules/react-native/android

> Configure project :react-native-screens
Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you should use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom(org.gradle.api.artifacts.Configuration[]) for more details.
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve org.webkit:android-jsc:+.
     Required by:
         project :app
      > Failed to list versions for org.webkit:android-jsc.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml.
            > Could not HEAD 'https://jcenter.bintray.com/org/webkit/android-jsc/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s

替换现在已经过时的jcenter()存储库与mavenCentral().

如果包裹丢失,我们仍然无法为他们提供mavenLocal() or a flatDir repo.

输出中有更多可疑的行,这暗示着一个疯狂的构建环境。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当我尝试运行 npx react-native run-android 时,任务:app:mergeDebugAssets 失败 的相关文章

随机推荐