Flutter升级后构建失败:Dex归档合并错误求助
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:
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.propertiesin your project - Add or ensure these lines are present:
android.useAndroidX=true android.enableJetifier=true
- Open
Update or replace the
device_infodependency
The warning explicitly calls outdevice_infoas a potential culprit—older versions of this package don't support AndroidX.- Open your
pubspec.yamlfile - Replace the old
device_infodependency withdevice_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 getto fetch the updated dependency
- Open your
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 runCheck 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 depsLook for dependencies that reference
com.android.supportin 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




