无法确定任务“:app:mergeDebugAssets”的依赖关系

22

当我在我的项目上运行react-native run-android时,我遇到了gradle的构建错误。我已经使用npm uninstall --save react-native-ftp卸载了react-native-ftp,并删除了node_modules中的该依赖项,清除了./gradle缓存文件。但错误仍然存在。

在我的Windows环境中,这个项目正常工作。

发生了什么?

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:mergeDebugAssets'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve project :react-native-ftp.
     Required by:
         project :app
      > Unable to find a matching configuration of project :react-native-ftp:
          - None of the consumable configurations have attributes.

* 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 2s

    at makeError (/home/leroto/leroto-workspace/svm/frontend/node_modules/execa/index.js:174:9)
    at /home/leroto/leroto-workspace/svm/frontend/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (/home/leroto/leroto-workspace/svm/frontend/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/home/leroto/leroto-workspace/svm/frontend/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)

4个回答

22

前往项目的 android 目录下,运行命令 ./gradlew clean 如果问题仍然存在,则删除 node_modules 文件夹并执行 npm install 或者您可以手动进行解决: 运行 npm list,然后解决所有的 UNMET DEPENDENCY 问题。


17

步骤1:检查您的所有“SDK平台”和“SDK工具”是否已安装并更新。

步骤2:在android文件夹中创建“local.properties”文件,并粘贴以下内容。

sdk.dir = /Users/USERNAME/Library/Android/sdk

这应该解决你的问题。


7
对于像我这样的新手。要更新 sdk platformstools,打开 Android studio,从下拉菜单 Configure 选择 SDK Manager,然后在 SDK platforms 标签和 SDK Tools 标签中勾选所有需要更新的内容,点击底部的应用按钮并等待... 完成后重新启动 VS Code,接受更改... - Fotios Tsakiris
所有上述事情都做了,但它不起作用,我在使用Mac。 - Sami Ullah
我所能弄清的就是我的Java-SDK版本,我安装了Java-SDK 8,一切都正常工作,代码无需更改。 - Sami Ullah

0
我在react-native-udp中找到了这个问题,进入nodemodules/react-native-udp/android/build.gradle并将
implementation 'com.facebook.react:react-native:0.11.+'替换为implementation 'com.facebook.react:react-native:0.70.4'

将模块名称更改为发生此问题的模块,并将版本号更改为您当前的react版本。


0

第一步

  1. 点击 Android 文件夹
  2. 点击 settings.gradle 文件
  3. 删除以下内容

include ':react-native-ftp'

project(':react-native-ftp').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ftp/android')

第二步

  1. 点击 Android 文件夹
  2. 点击 app 文件夹
  3. 点击 build.gradle 文件并删除

implementation project(':react-native-ftp')


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接