设置react-native-firebase后无法运行项目

问题描述 投票:0回答:2

基本上,我要问的是是否有人知道如何安装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?
react-native react-native-firebase
2个回答
0
投票

尝试运行这些命令。然后开始尝试再次运行您的应用]

cd android
./gradlew clean

0
投票

[尝试在Android Studio中构建Gradle。我发现在与react-native-firebase集成时,有时可以克服一些构建问题。在Android Studio中,通过导航到RN项目中的/ Android文件夹来打开android项目。让Gradle开始同步并监视所有错误详细信息。

您可能会在启动Android Studio时发现一些与JDK路径有关的问题。尝试在构建之前解决Android Studio报告的所有错误。

© www.soinside.com 2019 - 2024. All rights reserved.