模块react-native-fs和rn-fetch-blob的React Native构建失败

问题描述 投票:1回答:2

当我运行npm run android时,我正在构建失败(在Android上的macOS上),并且我得到以下构建失败:

FAILURE: Build failed with an exception.

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

显然,在node_modules/react-native-fs/androidnode_modules/rn-fetch-blob/android中我只看到一个IML文件而没有特定于模块的代码。我忘记了正确下载吗?我的android/settings.gradle文件如下:

rootProject.name = 'FooApp'
include ':react-native-version-number'
project(':react-native-version-number').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-version-number/android')
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/android')
include ':rn-fetch-blob'
project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android')
include ':react-native-google-signin'
project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-image-picker'
project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')

include ':app'

我错过了一些明显的东西吗

android react-native
2个回答
2
投票

我想只是运行命令

rm -rf node_modules && npm install

然后再运行react-native run-android再次可以解决


1
投票

您可以尝试删除文件夹node_modules并重新安装

rm -rf node_modules
npm install
react-native link

之后通过cd android && gradle clean清理android并再次运行android

© www.soinside.com 2019 - 2024. All rights reserved.