@capgo/capacitor-firebase-crashlytics

中文文档
8.3.1发布于 2026/09/14MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2251

Capacitor plugin for Firebase Crashlytics.

原始使用文档
文档目录28 节
  1. ➡️ Get Instant updates for your App with Capgo
  2. Missing a feature? We'll build the plugin for you 💪
  3. Compatibility
  4. Installation
  5. Android
  6. iOS
  7. Configuration
  8. Demo
  9. Starter templates
  10. Usage
  11. API
  12. crash(...)
  13. setCustomKey(...)
  14. setUserId(...)
  15. log(...)
  16. setEnabled(...)
  17. isEnabled()
  18. didCrashOnPreviousExecution()
  19. sendUnsentReports()
  20. deleteUnsentReports()
  21. recordException(...)
  22. getPluginVersion()
  23. Interfaces
  24. Type Aliases
  25. Test your implementation
  26. Changelog
  27. License
  28. Credits

@capgo/capacitor-firebase-crashlytics

Capgo - Instant updates for Capacitor

Unofficial Capacitor plugin for Firebase Crashlytics.[^1]

Compatibility

Plugin VersionCapacitor VersionStatus
8.x.x>=8.x.xActive support
7.x.x7.x.xDeprecated
6.x.x6.x.xDeprecated
5.x.x5.x.xDeprecated
1.x.x4.x.xDeprecated

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-firebase-crashlytics` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-firebase-crashlytics
npx cap sync

Add Firebase to your project if you haven't already (Android / iOS).

Android

Crashlytics Gradle plugin

First, add the dependency for the Crashlytics Gradle plugin to your root-level (project-level) Gradle file (<project>/build.gradle):

buildscript {
    dependencies {
+       // Add the dependency for the Crashlytics Gradle plugin
+       classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
    }
}

Add the Crashlytics Gradle plugin to your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle):

apply plugin: 'com.google.firebase.crashlytics'

Variables

If needed, you can define the following project variable in your app’s variables.gradle file to change the default version of the dependency:

  • $firebaseCrashlyticsVersion version of com.google.firebase:firebase-crashlytics (default: 20.0.3)

This can be useful if you encounter dependency conflicts with other plugins in your project.

iOS

To generate human readable crash reports, Crashlytics needs your project's debug symbol (dSYM) files. The following steps describe how to automatically upload dSYM files to Firebase whenever you build your app:

  1. Open your project's Xcode workspace, then select its project file in the left navigator.
  2. From the TARGETS list, select your main build target.
  3. Click the Build Settings tab, then complete the following steps so that Xcode produces dSYMs for your builds.
    1. Click All, then search for debug information format.
    2. Set Debug Information Format to DWARF with dSYM File for all your build types.
  4. Click the Build Phases tab and complete the following steps:
    1. Click the + button, then select New Run Script Phase.

      Make sure this new Run Script phase is your project's last build phase; otherwise, Crashlytics can't properly process dSYMs.

    2. Expand the new Run Script section.

    3. In the script field (located under the Shell label), add the run script based on your package manager:

      CocoaPods:

      "${PODS_ROOT}/FirebaseCrashlytics/run"
      

      Swift Package Manager:

      "${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
      
    4. In the Input Files section, add the paths for the locations of the following files based on your package manager:

      CocoaPods:

      ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}
      
      $(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
      

      Swift Package Manager:

      ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
      
      ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}
      
      ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist
      
      $(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/GoogleService-Info.plist
      
      $(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)
      

      If you have ENABLE_USER_SCRIPT_SANDBOXING=YES and ENABLE_DEBUG_DYLIB=YES in your project build settings, also include:

      ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}.debug.dylib
      

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-firebase-plugin-demo

Starter templates

The following starter templates are available:

Usage

import { FirebaseCrashlytics } from '@capgo/capacitor-firebase-crashlytics';

const crash = async () => {
  await FirebaseCrashlytics.crash({ message: 'Test' });
};

const setCustomKey = async () => {
  await FirebaseCrashlytics.setCustomKey({
    key: 'page',
    value: 'home',
    type: 'string',
  });
};

const setUserId = async () => {
  await FirebaseCrashlytics.setUserId({
    userId: '123',
  });
};

const log = async () => {
  await FirebaseCrashlytics.log({
    message: 'Test',
  });
};

const setEnabled = async () => {
  await FirebaseCrashlytics.setEnabled({
    enabled: true,
  });
};

const isEnabled = async () => {
  const { enabled } = await FirebaseCrashlytics.isEnabled();
  return enabled;
};

const didCrashOnPreviousExecution = async () => {
  const { crashed } = await FirebaseCrashlytics.didCrashOnPreviousExecution();
  return crashed;
};

const sendUnsentReports = async () => {
  await FirebaseCrashlytics.sendUnsentReports();
};

const deleteUnsentReports = async () => {
  await FirebaseCrashlytics.deleteUnsentReports();
};

const recordException = async () => {
  await FirebaseCrashlytics.recordException({
    message: 'This is a non-fatal message.',
  });
};

import * as StackTrace from 'stacktrace-js';
const recordExceptionWithStacktrace = async (error: Error) => {
  const stacktrace = await StackTrace.fromError(error);
  await FirebaseCrashlytics.recordException({
    message: 'This is a non-fatal message.',
    stacktrace,
  });
};

API

crash(...)

crash(options: CrashOptions) => Promise<void>

Forces a crash to test the implementation.

Only available for Android and iOS.

ParamType
optionsCrashOptions

Since: 0.1.0


setCustomKey(...)

setCustomKey(options: SetCustomKeyOptions) => Promise<void>

Sets a custom key and value that is associated with subsequent fatal and non-fatal reports.

Only available for Android and iOS.

ParamType
optionsCustomKeyAndValue

Since: 0.1.0


setUserId(...)

setUserId(options: SetUserIdOptions) => Promise<void>

Sets a user ID (identifier) that is associated with subsequent fatal and non-fatal reports.

Only available for Android and iOS.

ParamType
optionsSetUserIdOptions

Since: 0.1.0


log(...)

log(options: LogOptions) => Promise<void>

Adds a custom log message that is sent with your crash data to give yourself more context for the events leading up to a crash.

Only available for Android and iOS.

ParamType
optionsLogOptions

Since: 0.1.0


setEnabled(...)

setEnabled(options: SetEnabledOptions) => Promise<void>

Enables/disables automatic data collection. The value does not apply until the next run of the app.

Only available for Android and iOS.

ParamType
optionsSetEnabledOptions

Since: 0.1.0


isEnabled()

isEnabled() => Promise<IsEnabledResult>

Returns whether or not automatic data collection is enabled.

Only available for iOS.

Returns: Promise<IsEnabledResult>

Since: 0.1.0


didCrashOnPreviousExecution()

didCrashOnPreviousExecution() => Promise<DidCrashOnPreviousExecutionResult>

Returns whether the app crashed during the previous execution.

Only available for Android and iOS.

Returns: Promise<DidCrashOnPreviousExecutionResult>

Since: 0.1.0


sendUnsentReports()

sendUnsentReports() => Promise<void>

Uploads any unsent reports to Crashlytics at next startup.

When automatic data collection is enabled, Crashlytics automatically uploads reports at startup.

Only available for Android and iOS.

Since: 0.1.0


deleteUnsentReports()

deleteUnsentReports() => Promise<void>

Deletes any unsent reports on the device.

Only available for Android and iOS.

Since: 0.1.0


recordException(...)

recordException(options: RecordExceptionOptions) => Promise<void>

Records a non-fatal report to send to Crashlytics.

Only available for Android and iOS.

ParamType
optionsRecordExceptionOptions

Since: 0.1.0


getPluginVersion()

getPluginVersion() => Promise<GetPluginVersionResult>

Get the version of this plugin.

Returns: Promise<GetPluginVersionResult>

Since: 8.0.2


Interfaces

CrashOptions

PropTypeSince
messagestring0.1.0

CustomKeyAndValue

PropTypeSince
keystring7.1.0
valuestring | number | boolean7.1.0
type'string' | 'boolean' | 'long' | 'double' | 'int' | 'float'7.1.0

SetUserIdOptions

PropTypeSince
userIdstring0.1.0

LogOptions

PropTypeSince
messagestring0.1.0

SetEnabledOptions

PropTypeSince
enabledboolean0.1.0

IsEnabledResult

PropTypeSince
enabledboolean0.1.0

DidCrashOnPreviousExecutionResult

PropTypeSince
crashedboolean0.1.0

RecordExceptionOptions

PropTypeDescriptionSince
messagestringThe message to record as a non-fatal exception.0.1.0
codenumberError code within a specific error domain. Attention: This option is ignored on iOS if stacktrace is provided. Only available for iOS.0.1.0
domainstringA string containing the error domain. Attention: This option is ignored on iOS if stacktrace is provided. Only available for iOS.0.1.0
keysAndValuesCustomKeyAndValue[]An array of keys and the values to associate with the non fatal exception, in addition to the app level custom keys. Attention: This option is ignored on iOS if stacktrace is provided.7.1.0
stacktraceStackFrame[]A stacktrace generated by stacktrace.js.1.1.0

StackFrame

Subset of the Stacktrace generated by stacktrace.js.

PropType
lineNumbernumber
fileNamestring
functionNamestring

GetPluginVersionResult

PropTypeDescriptionSince
versionstringThe semantic version of this plugin.8.0.2

Type Aliases

SetCustomKeyOptions

CustomKeyAndValue

Test your implementation

Here you can find more information on how to test the Firebase Crashlytics implementation. Among other things, you will find information on how to correctly adjust the project's debug settings under iOS and how to test it out.

If you get obfuscated crash reports for iOS, make sure you have initialized Crashlytics correctly and take a look at this guide, which provides some ways to troubleshoot if Crashlytics can't find your app's dSYM.

Changelog

See CHANGELOG.md.

License

See LICENSE.

Credits

This plugin is based on the Capacitor Community Firebase Crashlytics plugin. Thanks to everyone who contributed to the project!

[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.

版本与发布记录

@capgo/capacitor-firebase-crashlytics 共发布 6 个版本,首次发布于 2025/11/24;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.3.1latest2026/09/141 个月前
8.0.22026/02/089 个月前
8.0.12026/02/089 个月前
7.4.22025/12/0411 个月前
7.4.12025/11/2411 个月前
7.4.02025/11/2411 个月前

关于 @capgo/capacitor-firebase-crashlytics 的常见问题

@capgo/capacitor-firebase-crashlytics 是什么?

Capacitor plugin for Firebase Crashlytics.

如何安装 @capgo/capacitor-firebase-crashlytics?

在项目目录运行 npm install @capgo/capacitor-firebase-crashlytics,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-firebase-crashlytics 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-firebase-crashlytics 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-firebase-crashlytics 可以商用吗?

@capgo/capacitor-firebase-crashlytics 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-firebase-crashlytics 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-firebase-crashlytics 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,251 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-firebase-crashlytics 还在维护吗?

最新版本 8.3.1 发布于 2026/09/14(1 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 6 个;首次发布于 2025/11/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。