基本上我想问的是,是否有人知道如何安装react-native-firebase并将项目连接到firebase?这应该是非常简单的,但它不起作用。
我在这里使用文档:https://rnfirebase.io/#2-android-setup
但是我正在安装react-native-firebase而不是react-native-firebase/app,因为我想使用react-native-firebase SDK
我正在使用以下命令创建一个新项目
npx react-native init newProject然后安装程序包:
npm install --save react-native-firebase然后创建一个新的frebase项目,将google-services.json添加到app文件夹,并添加模块:
classpath 'com.google.gms:google-services:4.3.3'(Android studio建议使用最新版本)
和:
apply plugin: 'com.google.gms.google-services'在那之后我就不能再运行这个项目了。它卡住了:
C:\Users\Omer\react-native1\haveri>npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1034 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
> Configure project :react-native-firebase
react-native-firebase: using React Native prebuilt binary from C:\Users\Omer\react-native1\haveri\node_modules\react-native\android
> Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
<============-> 99% EXECUTING [1m 11s] > IDLE > IDLE > IDLE > IDLE > IDLE > :app:installDebug
> IDLE
> IDLE如果我使用的是文档中指出的版本:
classpath 'com.google.gms:google-services:4.2.0'我得到了这个错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Unable to delete directory 'C:\Users\Omer\react-native1\haveri\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx' after 10 attempts
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Unable to delete directory 'C:\Users\Omer\react-native1\haveri\android\app\build\generated\not_namespaced_r_class_sources\debug\r\androidx' after 10 attempts
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
at makeError (C:\Users\Omer\react-native1\haveri\node_modules\execa\index.js:174:9)
at C:\Users\Omer\react-native1\haveri\node_modules\execa\index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async runOnAllDevices (C:\Users\Omer\react-native1\haveri\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\Users\Omer\react-native1\haveri\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)
This is all trying to install the react-native-firebase on a brand new project.
What am I doing wrong? How can I install it successfully?发布于 2020-04-15 15:44:06
尝试运行这些命令。然后开始尝试再次运行您的应用程序
cd android
./gradlew clean发布于 2020-04-15 18:10:19
尝试在Android studio中构建Gradle。我发现,在与react-native-firebase集成时,这有时会克服一些构建问题。在Android studio中,导航到RN项目中的/Android文件夹,打开android项目。让Gradle开始同步并监控任何错误细节。
在启动Android Studio时,您可能会发现一些与JDK路径相关的问题。在构建之前,尝试排除Android Studio报告的所有错误。
https://stackoverflow.com/questions/61223373
复制相似问题