未找到名称"default"的配置 - React Native

zoe*_*ver 11 android react-native react-native-android

当我运行时,react-native run-android我收到以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
   > Configuration with name 'default' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Run Code Online (Sandbox Code Playgroud)

我知道这意味着存在一些链接错误,但我无法弄清楚是什么.我很乐意帮助修复,我对android很新.

rek*_*eku 34

如果build.gradle找不到某个程序包依赖项,则会发生这种情况.

要调试此问题,请在您的react本机项目中运行

cd android
./gradlew clean --info
Run Code Online (Sandbox Code Playgroud)

运行此命令后,您可以看到建筑物停止的位置.转到那个包github页面并搜索问题.你很可能会找到答案.在我的情况下,这是因为react-native-maps,所以我必须修改settings.gradle以指出该build.gradle包的真实位置

  • 这非常有用,谢谢!我发生的事情是`react-native unlink`没有完全卸载一个包.它在`MainApplication.java`中留下了一行.我已经卸载了npm包,所以它试图找到一个不存在的目录.所以我只需要手动删除`MainApplication.java`中的行. (2认同)