问题
i'm building app with ionic i have add firebase cloud message, everything work fine But today, when i build that show error.
- ionic cordova platform rm android
- remove plugins
- clear & clean cache
- remove package-lock.js
- npm i 6 ionic cordova platform add android 7 ionic cordova prepare 8 ionic cordova build android
Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED 37 actionable tasks: 7 executed, 30 up-to-date D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 18s /////*/platforms/android/gradlew: Command failed with exit code 1 Error output: D8: Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes. Program type already present: android.support.v4.os.ResultReceiver$MyResultReceiver
回答1:
I had the same issue, and found out it was because of the firebase and googleplus plugins. Finally found a solution that worked for me :
ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter
Simply adding these plugins removed any build error.
来源:https://stackoverflow.com/questions/56688570/program-type-already-present-android-support-v4-os-resultreceivermyresultrecei