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

Flutter集成firebase_core时触发Gradle构建错误::app:checkDebugDuplicateClasses

Flutter集成firebase_core时触发Gradle构建错误::app:checkDebugDuplicateClasses

我之前碰到这个Gradle重复类的错误时,首先确认了Firebase的基础配置流程有没有走对,你可以先跟着过一遍这些操作步骤,确保配置没问题:

Setup

  • 在VSCode中创建一个新的Flutter项目,选择Empty Application模板,项目命名为hello_fire
  • 运行命令激活flutterfire_cli工具:dart pub global activate flutterfire_cli
  • 启动Firebase配置向导:flutterfire configure

接下来是配置过程中的终端交互记录,你可以参考这个流程来完成项目与Firebase的绑定:

✔ Select a Firebase project to configure your Flutter application with · fir-test-ab0e1 (Firebase Test)
✔ Which platforms should your configuration support (use arrow keys & space to select)? · android, ios, macos, web, windows
✔ Which Android application id (or package name) do you want to use for this configuration, e.g. 'com.example.app'? · com.example.hello_fire
i Firebase android app com.example.hello_fire is not registered on Firebase project fir-test-ab0e1.
i Registered a new Firebase android app on Firebase project fir-test-ab0e1.
i Firebase ios app com.example.helloFire is not registered on Firebase project fir-test-ab0e1.
i Registered a new Firebase ios app on Firebase project fir-test-ab0e1.
i Firebase macos app com.example.helloFire registered.
i Firebase web app hello_fire (web) registered.

如果完成以上配置后仍然出现重复类错误,大概率是依赖版本冲突导致的。你可以尝试以下几点:

  1. 检查pubspec.yaml中firebase_core的版本,确保它和其他Firebase依赖版本适配
  2. 打开Android项目的build.gradle文件,在dependencies块中通过exclude group:语法排除重复引入的类库
  3. 执行flutter clean和flutter pub get清理缓存后重新构建项目

备注:内容来源于stack exchange,提问作者GniLudio

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.16 11:33:17