你的堆栈跟踪开始于:error: cannot find symbol import com.facebook.react.ReactApplication
这似乎表明它找不到 React 库导入。
我将在 Github 上为您提供一个答案,请阅读此处:
https://github.com/transistorsoft/react-native-background-geolocation/issues/294 https://github.com/transistorsoft/react-native-background-geolocation/issues/294
(顺便说一句,这与你的 build.gradle 有关/your-project/android/build.gradle
)
如果其他人遇到同样的问题:请确保正确添加新存储库。根据 Android 文档,每个 Maven 存储库都应该位于自己的 Maven {} 块中。
这就是为什么
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
url 'some new extra repo'
}
打破依赖关系。
正确的版本是
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'some new extra repo'
}
UPDATE
由于上述内容没有解决您的问题,并且您的 build.gradle 看起来不错(对我来说)。我将包括一些其他解决方案:
按照此处的建议升级 RN 和 RN-cli:
无法解析符号 ReactApplication/ReactNativeHost https://stackoverflow.com/questions/49120454/cannot-resolve-symbol-reactapplication-reactnativehost
另一个在这里:
失败:构建失败,在反应原生 Android 中出现异常 https://stackoverflow.com/questions/41471679/failure-build-failed-with-an-exception-in-react-native-android
另一个在这里:
React Native Android 错误:找不到符号 https://stackoverflow.com/questions/39501382/react-native-android-error-cannot-find-symbol
最后一招
It may值得创建一个新的测试项目(使用最新版本),例如react-native init anotherproject
看看是否可以运行。