报错详细信息:

  1. Could not determine the dependencies of task ':app:preDebugBuild'.
  2. > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
  3. > Could not resolve project :react-native-date-picker.
  4. Required by:
  5. project :app
  6. > Unable to find a matching configuration of project :react-native-date-picker:
  7. - None of the consumable configurations have attributes.

背景:

RN项目需求让用户选择时间,格式 “小时:分钟”

实际操作:

打算引入 react-native-date-picker 这个组件

结果:

引入之后,在 WebStorm 终端编译完成且成功,但是在 node “D:...(PS:项目路径)” start 窗口中并没有向安卓模拟器发送安装包文件,如下图
image.png
按下 “r” 键, 之后就一直显示 appReloading… 卡在这里不动了

然后就移除 react-native-date-picker 组件, 使用命令 yarn remove react-native-date-picker

移除之后,发现项目跑不起来了,编译就会报错: 如标题 ,详细信息在开头

解决办法:

在 android/app/bulid.gradle 文件中 ,如下图image.png
将 dependencies 中的 implementation project(':react-native-date-picker') 删除

另外在 android/settings.gradle 文件中 删除与 react-native-date-picker 有关的如下:

  1. include ':react-native-date-picker'
  2. project(':react-native-date-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-date-picker/android')

然后就可以了