首页 > 解决方案 > 运行反应本机应用程序时出错

问题描述

我正在安装 react native,同时在 windows 中的 react native android 中运行我的第一个应用程序。我收到错误

无法确定任务 ':app:preDebugBuild' 的依赖关系。> 无法解析配置 ':app:debugRuntimeClasspath' 的所有任务依赖项。> 无法解析项目:react-native-default-preference。要求:项目:应用程序>无法找到项目的匹配配置:react-native-default-preference:所有消耗性配置都没有属性。在本机反应

标签: androidreact-nativeandroid-emulator

解决方案


您应该清除缓存并重试

RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && 
npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 -  watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && 
rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm 
install && npm start -- --reset-cache

npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && 
npm cache verify && npm install && npm start -- --reset-cache

Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del 
node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache

答案来自https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d


推荐阅读