Search code examples
androidcordovafirebaseionic-frameworkcordova-plugin-fcm

Error with Ionic App: execution failed for task ':transformClassesWithJarMergingForDebug'


I checked all the posts speaking about this error:

Execution failed for task ':transformClassesWithJarMergingForDebug'

But none of them match exactly my case here and none of them answered/solved my issue... I'm tired of searching (about 12 hours and haven't find anything...)

Explaination

I'm using Ionic (last version) to build an app. My first issue was about the SenderID problem: cannot put it in the init function, but when I removed it, it wasn't working on Android... And when I put it, it said that it is not assignable to PushOptions, you see the trick.

Actual error

The actual error that I have is the following:

Execution failed for task ':transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/cordova/BuildHelper.class

Here what I've done to be here:

Steps

So I decided to switch to cordova-plugin-fcm as I see at different places that it is easy to configure it. Jump through it, generate all the necessary files (google-services.json etc...) install and run all the TS that the plugin need: no TS errors.

My problem: when I run ionic cordova run android - or just a build, it's the same - I had multiples issues:

First error

First I had an issue about play-services that is unknown so it will jump through version 9.0.0: I solved it by using cordova-plugin-firebase instead and cordova-android-play-services-gradle-release.

Second Error

Secondly I had this one:

Execution failed for task ':transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/cordova/PermissionHelper.class

That I resolved using:

cordova plugin rm cordova-plugin-compat --force
cordova plugin add [email protected]

But now, I'm stuck with the "Actual error" and no way to build my app.

Stack

Cordova plugins:

cordova-android-play-services-gradle-release 1.1.3 "cordova-android-play-services-gradle-release"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-browsertab 0.2.0 "cordova-plugin-browsertab"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-firebase 0.1.24 "Google Firebase Plugin"
cordova-plugin-multidex 0.1.2 "Cordova Multi Dex"
cordova-plugin-splashscreen 4.0.2 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Solution

  • Here's what I did to get rid of this problem:

    • Remove your platforms:
    ionic cordova platform remove ios
    ionic cordova platform remove android
    
    • Remove the following directories in your app:
    \platforms
    \plugins
    
    • re-add your platforms:
    ionic cordova platform add ios
    ionic cordova platform add android
    

    After that you can re-build the app and it should work