D8: Program type already present: org.apache.cordo

2019-08-25 04:22发布

问题:

While running $ ionic cordova build android the build fails.

Tried to install the npm plugin cordova-android-support-gradle-release but got this issue: https://github.com/dpa99c/cordova-android-support-gradle-release/issues/42

There's actually no specific code I've written for this to happen.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.

    com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: 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: org.apache.cordova.BuildHelper

回答1:

I was able to fix the issue by removing those duplicated .java classes from the CordovaLib sub project.