You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native使用react-native-firebase Storage报错:Android模块未安装

Fixing "You attempted to use a firebase module that's not installed on your android project by calling firebase.storage()" in React Native Firebase

Let's walk through the most common fixes for this error—even if you think you've covered all bases, there's usually a small configuration step missing that's causing the issue.

1. Ensure the Storage module is actually installed

It's easy to overlook that @react-native-firebase/storage is a standalone module separate from the core @react-native-firebase/app or @react-native-firebase/core packages. Run this command to install it (depending on your package manager):

# Using npm
npm install @react-native-firebase/storage

# Using yarn
yarn add @react-native-firebase/storage

2. Verify Android project configuration

Even with auto-linking (for RN 0.60+), sometimes the module doesn't link properly. Double-check these files:

android/settings.gradle

Make sure these lines are present (auto-linking should add them, but manual checks never hurt):

include ':react-native-firebase-storage'
project(':react-native-firebase-storage').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/storage/android')

android/app/build.gradle

Confirm the Storage dependency is listed in the dependencies block:

dependencies {
  // ... other dependencies
  implementation project(':react-native-firebase-storage')
}

MainApplication.java

If auto-linking failed, you'll need to manually add the Storage package:

  1. Import the package at the top:
import io.invertase.firebase.storage.ReactNativeFirebaseStoragePackage;
  1. Add it to the getPackages() method:
@Override
protected List<ReactPackage> getPackages() {
  @SuppressWarnings("UnnecessaryLocalVariable")
  List<ReactPackage> packages = new PackageList(this).getPackages();
  // Add this line
  packages.add(new ReactNativeFirebaseStoragePackage());
  return packages;
}

3. Clean caches and rebuild

Corrupted build caches are a frequent culprit. Run these commands in order:

# Clean npm/yarn cache
npm cache clean --force
# Or for yarn: yarn cache clean

# Clean Android build files
cd android && ./gradlew clean

# Go back to root and rebuild the app
cd .. && react-native run-android

4. Check version compatibility

Ensure all your @react-native-firebase/* packages are on the same major version. Mismatched versions (e.g., core on v18 but storage on v17) can cause module resolution issues. Check your package.json to confirm:

{
  "@react-native-firebase/core": "^18.0.0",
  "@react-native-firebase/storage": "^18.0.0"
}

5. Confirm Firebase project setup

Double-check that your google-services.json file is placed in the android/app directory and that it's the correct file for your Firebase project. A missing or incorrect config can prevent modules from initializing properly.

Bonus: Ensure AndroidX compatibility

If you're using an older React Native version, make sure your project is configured for AndroidX (required by modern Firebase modules). Add these lines to android/gradle.properties:

android.useAndroidX=true
android.enableJetifier=true

内容的提问来源于stack exchange,提问作者Italo Fernández Salgado

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:00:47