首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >设置react-native-firebase后无法运行项目

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

Stack Overflow用户
提问于 2020-04-15 15:20:59
回答 2查看 2.5K关注 0票数 0

基本上我想问的是,是否有人知道如何安装react-native-firebase并将项目连接到firebase?这应该是非常简单的,但它不起作用。

我在这里使用文档:https://rnfirebase.io/#2-android-setup

但是我正在安装react-native-firebase而不是react-native-firebase/app,因为我想使用react-native-firebase SDK

我正在使用以下命令创建一个新项目

代码语言:javascript
复制
npx react-native init newProject

然后安装程序包:

代码语言:javascript
复制
npm install --save react-native-firebase

然后创建一个新的frebase项目,将google-services.json添加到app文件夹,并添加模块:

代码语言:javascript
复制
classpath 'com.google.gms:google-services:4.3.3'

(Android studio建议使用最新版本)

和:

代码语言:javascript
复制
apply plugin: 'com.google.gms.google-services'

在那之后我就不能再运行这个项目了。它卡住了:

代码语言:javascript
复制
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

如果我使用的是文档中指出的版本:

代码语言:javascript
复制
classpath 'com.google.gms:google-services:4.2.0'

我得到了这个错误:

代码语言:javascript
复制
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?
EN

回答 2

Stack Overflow用户

发布于 2020-04-15 15:44:06

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

代码语言:javascript
复制
cd android
./gradlew clean
票数 0
EN

Stack Overflow用户

发布于 2020-04-15 18:10:19

尝试在Android studio中构建Gradle。我发现,在与react-native-firebase集成时,这有时会克服一些构建问题。在Android studio中,导航到RN项目中的/Android文件夹,打开android项目。让Gradle开始同步并监控任何错误细节。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61223373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档