1
votes

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

3
thank you for the comment @DaveAlden. I tried with the [email protected] and also removing the .java classes but none of the options workedmluis
@DaveAlden it seems that by deleting those .java files from the CordovaLib it compiles. Would you mind responding so I can approve your answer?mluis
I don't want to create a duplicate answer or an answer that's simply a link - both are frowned upon by moderatorsDaveAlden

3 Answers

7
votes

Thanks! I also was able to fix this issue by deleting the following files:

  • PermissionHelper.java
  • BuildHelper.java

In this folder: ⁨platforms⁩ ▸ ⁨android⁩ ▸ ⁨app⁩ ▸ ⁨src⁩ ▸ ⁨main⁩ ▸ ⁨java⁩ ▸ ⁨org⁩ ▸ ⁨apache⁩

2
votes

I solved this by removing cordova-plugin-compat from my cordova project as it's deprecated and the functionality is now part of cordova for android.

This plugin is no longer being worked on as the functionality provided by this plugin is now included in cordova-android 6.3.0. You should upgrade your application to use version 1.2.0 of this plugin. It will detect whether or not the plugin is required based on the version of cordova-android your app uses.

1
votes

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