如何修复无法与离子中的dex合并?

Moh*_*raj 3 android build ionic-framework ionic3

在进行 android 构建时,我遇到了问题。

任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败

任务 :CordovaLib:compileDebugShaders UP-TO-DATE 任务 :CordovaLib:generateDebugAssets UP-TO-DATE 任务 :CordovaLib:packageDebugAssets UP-TO-DATE 任务 :app:mergeDebugAssets 任务 :app:validateSigningDebug UP-TO-DATE 任务配置器 :app:signing最新任务 :app:transformClassesWithDexBuilderForDebug 最新任务

任务:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8:程序类型已经存在:android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE:构建失败,出现异常。

  • 出了什么问题:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。

    com.android.builder.dexing.DexArchiveMergerException:合并 dex 档案时出错:在https://developer.android.com/studio/build/dependencies#duplicate_classes了解如何解决该问题。程序类型已经存在:android.support.v4.os.ResultReceiver$MyResultReceiver

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org获取更多帮助

在 22 秒内构建失败 35 个可操作任务:3 个已执行,32 个最新 /Users/panmoh/Documents/mobile-app/platforms/android/gradlew:命令失败,退出代码 1 错误输出:D8:程序类型已存在: android.support.v4.os.ResultReceiver$MyResultReceiver

FAILURE:构建失败,出现异常。

  • 出了什么问题:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。

    com.android.builder.dexing.DexArchiveMergerException:合并 dex 档案时出错:在https://developer.android.com/studio/build/dependencies#duplicate_classes了解如何解决该问题。程序类型已经存在:android.support.v4.os.ResultReceiver$MyResultReceiver

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。使用 --scan 运行以获得完整的见解。

  • https://help.gradle.org获取更多帮助

BUILD FAILED in 22s [ERROR] 运行子进程cordova 时出错。

    cordova build android exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.
Run Code Online (Sandbox Code Playgroud)

注意:我也尝试cordova clean android删除并添加了 android 平台

Med*_*rix 5

为使用 Phonegap/Cordova 的用户解决此问题

  • 安装“cordova-plugin-androidx”插件

    cordova plugin add cordova-plugin-androidx

  • 安装“cordova-plugin-androidx-adapter”插件

    cordova plugin add cordova-plugin-androidx-adapter

  • 在 gradle.properties 中添加这些行:

    android.useAndroidX=true android.enableJetifier=true

在此之后,进行构建:cordova -d build android并检查结果