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

Flutter集成Google Sign-In遇Android端Unable to merge dex构建错误求助

Fixing Dex Merge Error with Flutter Firebase Auth on Android

Hey there! Let's tackle this dex merge issue you're facing with Flutter and Firebase Authentication on Android—totally get why this is frustrating, especially since everything works smoothly on iOS. Here are some straightforward, beginner-friendly fixes you can try without diving too deep into Gradle configurations:

1. Update Your Dependencies to the Latest Stable Versions

Your google_sign_in: 0.3.1 version is quite outdated, and old dependency versions often clash with newer Flutter or Firebase SDKs. Head over to your pubspec.yaml file and update the dependency to the latest stable release (e.g., google_sign_in: ^5.4.0). After making the change, run:

flutter pub get

2. Enable Multidex for Your Android Project

A common cause of this dex merge error is hitting Android's 65k method count limit. Enabling multidex is a simple fix:

  • Open app/build.gradle, find the defaultConfig block, and add:
    multiDexEnabled true
    
  • In the same file's dependencies section, add this line:
    implementation 'androidx.multidex:multidex:2.0.1'
    

Save the file and try running your app again with flutter run.

3. Clean and Rebuild Your Project

Cached build files can sometimes cause weird conflicts. Clear them out with these commands:

flutter clean
cd android && ./gradlew clean
cd .. && flutter run

4. Check for Duplicate Dependencies (If All Else Fails)

Occasionally, indirect dependencies can introduce duplicate Android libraries. You can run this command to view your full dependency tree and spot duplicates:

flutter pub deps

Look for any repeated Android-related libraries and adjust your dependencies accordingly, but this is a last-resort step—most of the time, the first three fixes will resolve the issue.

If you still run into trouble, double-check that the Google Services classpath in your root build.gradle is using the latest stable version (e.g., classpath 'com.google.gms:google-services:4.3.10').

内容的提问来源于stack exchange,提问作者Serge B.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:50:33