You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Flutter升级后构建失败:Dex归档合并错误求助

Fixing Flutter Build Failure After flutter update & flutter packages update

Hey there, let's work through this build issue you're facing. The error you're seeing (Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy) and the warning about device_info point straight to a conflict between AndroidX libraries and the old Android Support Libraries—this is super common after updating Flutter dependencies.

Here's how to resolve it step by step:

  1. Enable AndroidX and Jetifier in your project
    Jetifier automatically converts old Support Library dependencies to their AndroidX equivalents, which eliminates these dex merge conflicts.

    • Open android/gradle.properties in your project
    • Add or ensure these lines are present:
      android.useAndroidX=true
      android.enableJetifier=true
      
  2. Update or replace the device_info dependency
    The warning explicitly calls out device_info as a potential culprit—older versions of this package don't support AndroidX.

    • Open your pubspec.yaml file
    • Replace the old device_info dependency with device_info_plus (the maintained, AndroidX-compatible successor):
      dependencies:
        # Replace device_info with this:
        device_info_plus: ^8.2.0 # Use the latest stable version available
      
    • Run flutter pub get to fetch the updated dependency
  3. Perform a full clean of build caches
    Old cached build files might still be causing conflicts, so let's wipe them entirely:

    flutter clean
    cd android
    ./gradlew clean
    ./gradlew build --refresh-dependencies
    cd ..
    flutter run
    
  4. Check for other conflicting dependencies
    If the issue persists, use this command to generate a full dependency tree and spot any other packages still using old Support Libraries:

    flutter pub deps
    

    Look for dependencies that reference com.android.support in their Android dependencies, then upgrade those packages to versions that support AndroidX.

Why this works:

After running flutter update and flutter packages update, your dependencies likely pulled in newer versions that expect AndroidX support. The old device_info package and missing Jetifier setup meant your project was mixing AndroidX and old Support Library classes—leading to the duplicate class error during dex merging. Switching SDK versions alone doesn't fix this dependency conflict, but the steps above address the root cause.

内容的提问来源于stack exchange,提问作者Blondy314

火山引擎 最新活动