繁体   English   中英

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

[英]Task :app:mergeDebugAssets FAILED when I try to run npx react-native run-android

我正在使用 vscode 和物理 android 设备在 react-native 上开发 android 应用程序,并且在尝试使用 npx211ZB0DF27BCECAEB30D4 构建时,它一直显示以下错误

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
    }
}

Output of./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

用 mavenCentral() 替换现在过时的jcenter() mavenCentral()库。

如果缺少包,仍然不能为它们提供mavenLocal()flatDir库。

output 有更多可疑的行,这暗示了一个疯狂的构建环境。

我改变了 android\build.gradle

...
    repositories {
        ...
        mavenCentral() //jcenter()
    }
...
allprojects {

    repositories {
        ...
        mavenCentral()
        jcenter() {
            content {
                includeModule("com.facebook.yoga", "proguard-annotations")
                includeModule("com.facebook.fbjni", "fbjni-java-only")
                includeModule("com.yqritc", "android-scalablevideoview")
            }
        }

我改变android\gradle.properties

FLIPPER_VERSION=0.99.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM