当前位置: 首页 > 知识库问答 >
问题:

当我尝试运行npx反应原生运行Android时,合并Debug资产失败

孙熠彤
2023-03-14

我正在使用vscode和一个物理的android设备,在react-本地上开发一个android应用程序,它在尝试使用npx react-本地运行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清理并再次尝试构建应用程序
  2. 已启用多索引已在应用程序/内部版本中启用。格拉德尔
  3. 我正在使用一个物理android设备来运行这个应用程序。我尝试卸载该应用程序,并尝试再次构建该应用程序
  4. 已删除节点_模块,清除了npm缓存,并再次尝试安装所有节点_模块

有人知道怎么解决这个问题吗?

下面是关于这个项目的一些细节

包裹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构建警告模式的输出

> 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

共有1个答案

齐志勇
2023-03-14

将现已过时的jcenter()存储库替换为mavenCentral()

如果缺少软件包,not仍然可以向他们提供mavenLocal()flatDirrepo。

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

 类似资料:
  • 我已经被困了两天了,我正在尝试设置,一切都就绪了:最新的Android Studio、Genymotion、Path.io/react-native/docs/geting-started.html上的所有指导。 当我运行或时,我会得到以下错误: C:\users\pc\desktop\bot>react-native run-android系统找不到指定的路径。child_process.js:

  • 失败:生成失败,出现异常。 > 错误:任务“:app:installdebug”执行失败。 com.android.builder.testing.api.deviceException:没有连接的设备! 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。 请访问https://help.gr

  • info JS服务器已在运行。安装应用程序的信息。。。 任务:@react-native-community_datetimepicker:compiledBugJavaWithJavaC 任务:react-nate-fbsdk: compileDebugJavaBackJavac 任务:反应本机手势处理程序:CompiledBugJavaWithJavaC 任务:反应本机映射:CompiledB

  • 清单合并失败:[com.android.support:percent:26.0.2]androidmanifest.xml:25:13-35中的属性元数据#android.support.version@value value=(26.0.2)也出现在[com.android.support:support-v4:26.1.0]androidmanifest.xml:28:13-35 value

  • 对于这个错误我该怎么做呢? 错误:任务“:app:DexDebug”执行失败。 当我尝试运行我的应用程序时,这个问题就会出现。