无法为Android构建React-Native应用

时间:2017-06-13 17:11:20

标签: android gradle react-native

我最近开始研究仅在ios中实现的现有React Native应用程序,并开始尝试在Android上构建和开发它。我按照React Native文档中的所有说明进行操作,但不断收到此错误并且无法找出原因:

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

基于研究,我假设它必须与我的settings.gradle文件有关,但我无法弄清楚是什么。这就是该文件的样子:

include ':react-native-firebase-analytics'
project(':react-native-firebase-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase-analytics/android')
include ':tipsi-stripe'
project(':tipsi-stripe').projectDir = new File(rootProject.projectDir, '../node_modules/tipsi-stripe/android')
include ':react-native-sentry'
project(':react-native-sentry').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sentry/android')
include ':react-native-webview-bridge'
project(':react-native-webview-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview-bridge/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-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')

include ':ReactAndroid'

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

include ':app'

有谁知道为什么会这样,以及如何解决?谢谢!

1 个答案:

答案 0 :(得分:0)

我刚刚解决了这个问题。有时,当您使用npm或更具体地 uninstall 安装RN软件包时,代码在Android文件中是剩余的。确保您不包含任何不再使用的包裹。您可以在app/build.gradle文件和settings.gradle文件中手动删除此软件包,这对我有用。