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

使用Ionic Cordova构建Android APK时Firebase Crashlytics报错如何解决?

修复Ionic Cordova Android构建时的Crashlytics Gradle错误

问题场景

执行构建命令:

ionic cordova build android

出现以下错误:

  • What went wrong:
    A problem was found with the configuration of task ':app:injectCrashlyticsMappingFileIdDebug' (type 'InjectMappingFileIdTask').
    • In plugin 'com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsPlugin' type 'com.google.firebase.crashlytics.buildtools.gradle.tasks.InjectMappingFileIdTask' field 'resourceFile' without corresponding getter has been annotated with @OutputFile.

      Reason: Annotations on fields are only used if there's a corresponding getter for the field.

      Possible solutions:

      1. Add a getter for field 'resourceFile'.
      2. Remove the annotations on 'resourceFile'.

使用的依赖版本:

"java": "11.0.17"
"gradle": "7.4.2"
"@angular/cli": "~10.0.5"
"@ionic/angular": "^5.3.5"
"cordova-android": "10.1.2"

修复步骤

该错误由Firebase Crashlytics Gradle插件与当前Gradle版本不兼容导致,可通过以下方式解决:

方法一:升级Cordova Crashlytics插件

  1. 卸载旧插件:
ionic cordova plugin remove cordova-plugin-firebase-crashlytics
npm uninstall @ionic-native/firebase-crashlytics
  1. 安装最新兼容版本:
npm install @ionic-native/firebase-crashlytics@latest
ionic cordova plugin add cordova-plugin-firebase-crashlytics@latest

方法二:手动升级Crashlytics Gradle插件版本

  1. 打开platforms/android/build.gradle,找到Crashlytics插件依赖,将版本替换为2.9.2及以上:
dependencies {
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
}
  1. 清理缓存并重新构建:
ionic cordova clean android
ionic cordova build android

方法三:降级Gradle版本

若前两种方法无效,可将Gradle降级至与cordova-android 10.1.2更匹配的7.0.x版本:

  1. 修改platforms/android/gradle/wrapper/gradle-wrapper.properties中的distributionUrl:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
  1. 清理缓存后重新执行构建命令。

内容的提问来源于stack exchange,提问作者Shah Newaj Rabbi Shishir

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 10:02:38