DuplicateFileException When building ionic app for android

166 views Asked by At

I'm trying to build my app for android, and ever since I updated my android-cordova to 6.2.3 I have not been able to build my app for android anymore.

Rolling back to android-cordova 6.1.1 didn't help, I was unable to build again after the previous upgrade.

The full error is

* What went wrong:
Execution failed for task ':transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate file
s copied in APK META-INF/rxjava.properties
        File1: /Users/admin/Desktop/Gravity/clubezy-meteorionic/platforms/android/build/intermediates/exploded-aar/com.goo
gle.android.gms/play-services-basement/11.0.0/jars/classes.jar
        File2: /Users/admin/.gradle/caches/modules-2/files-2.1/io.reactivex/rxjava/1.1.9/e4362e62f1ba92e360b197d6d7ffae67e
5ecae9a/rxjava-1.1.9.jar

I have a suspicion that it could be an issue with one of my cordova plugins that may be causing this.

This is my environment and plugins.

ionic info: 
global packages:

@ionic/cli-utils : 1.4.0 
Cordova CLI : 7.0.1 
Ionic CLI : 3.4.0

local packages:

@ionic/app-scripts : 1.3.7 
@ionic/cli-plugin-cordova : 1.4.0 
@ionic/cli-plugin-ionic-angular : 1.3.1 
Cordova Platforms : ios 4.4.0, android 6.2.3
Ionic Framework : ionic-angular 3.4.2

System:

Node : v6.10.3 
OS : Linux 4.4 
Xcode : not installed 
ios-deploy : not installed 
ios-sim : not installed 
npm : 5.0.3

cordova plugin ls

com.instabug.cordova.plugin 1.0.0 "instabug-cordova" 
cordova-plugin-3dtouch 1.3.5 "3D Touch" 
cordova-plugin-app-version 0.1.9 "AppVersion" 
cordova-plugin-camera 2.3.1 "Camera" 
cordova-plugin-compat 1.1.0 "Compat" 
cordova-plugin-console 1.0.5 "Console" 
cordova-plugin-device 1.1.6 "Device" 
cordova-plugin-file 4.3.3 "File" 
cordova-plugin-file-transfer 1.6.3 "File Transfer" 
cordova-plugin-multidex 0.1.1 "Cordova Multi Dex" 
cordova-plugin-splashscreen 4.0.3 "Splashscreen" 
cordova-plugin-statusbar 2.2.3 "StatusBar" 
cordova-plugin-whitelist 1.3.1 "Whitelist" 
ionic-plugin-keyboard 2.2.1 "Keyboard" 
onesignal-cordova-plugin 2.0.11 "OneSignal Push Notifications"

The plugin I think may be causing this is the instabug one.

~edit

After adding each plugin one at a time either

com.instabug.cordova.plugin or cordova-plugin-multidex

is causing it

multidex is a dependancy of instabug

2

There are 2 answers

0
Nicholas Tsaoucis On BEST ANSWER

To get it to build on my iOS and Linux build machines I changed the build.gradle to have this.

android {
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
        }
    }

    defaultConfig {
        applicationId = doExtractStringFromManifest("package")
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/rxjava.properties'
    }
}

It now seems to be building correctly, I created a branch with the changes so I could pull it from github to install via the packages.

0
Nicholas Tsaoucis On
    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.2.3
    Ionic Framework                 : ionic-angular 3.4.2

System:

    Node       : v8.1.1
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 5.0.3

com.instabug.cordova.plugin 1.0.0 "instabug-cordova"
cordova-plugin-3dtouch 1.3.5 "3D Touch"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.7 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-multidex 0.1.1 "Cordova Multi Dex"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
onesignal-cordova-plugin 2.1.2 "OneSignal Push Notifications"

Building on my windows machine, I've updated my plugins and the environment is the same and I no longer get the error above. Not exactly sure what was causing the clashes though so not really an answer.