1

I am trying to get all the libraries for docx4j obtained here: https://stackoverflow.com/a/23710079/1616685

I set up MultiDex successfully, however I get a duplicated entry error:

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: org/apache/harmony/awt/internal/nls/Messages.class

as you can see there are a lot of libraries to compile... it is easy to have duplicates, is there a way to avoid from the gradle such errors?

here the gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    defaultConfig {
        applicationId "com.example.test_images"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
    }
    dexOptions {
        preDexLibraries = false
//        incremental true
        javaMaxHeapSize "4g"
        incremental true
    }
    productFlavors {
    }
    compileOptions {
    }
}

subprojects {
    project.plugins.whenPluginAdded { plugin ->
        if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
            project.android.dexOptions.preDexLibraries = false
        } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
            project.android.dexOptions.preDexLibraries = false
        }
    }
}
afterEvaluate {
    tasks.matching {
        it.name.startsWith('dex')
    }.each { dx ->
        if (dx.additionalParameters == null) {
            dx.additionalParameters = ['--multi-dex']
        } else {
            dx.additionalParameters += '--multi-dex'
        }
    }
}

dependencies {
    compile ('com.android.support:multidex:1.0.0'){ exclude group: 'java.util.zip' }
    compile ('com.android.support:appcompat-v7:22.2.0')
    compile ('com.parse.bolts:bolts-android:1.+')
    compile files('libs/activation.jar')
    compile files('libs/additionnal.jar')
    compile files('libs/ae-awt.jar')
    compile files('libs/ae-docx4j-2.8.0-SNAPSHOT.jar')
    compile files('libs/ae-jaxb-2.2.5.jar')
    compile files('libs/ae-xmlgraphics-commons.jar')
    compile files('libs/avalon-framework-api-4.3.1.jar')
    compile files('libs/avalon-framework-impl-4.3.1.jar')
    compile files('libs/commons-codec-1.3.jar')
    compile files('libs/commons-io-1.3.1.jar')
    compile files('libs/commons-lang-2.4.jar')
        compile files('libs/commons-logging-1.1.1.jar')
    compile files('libs/droidText.0.4.jar')
    compile files('libs/istack-commons-runtime.jar')
    compile files('libs/JAXBNamespacePrefixMapper-2.2.4.jar')
    compile files('libs/jaxp-datatype.jar')
    compile files('libs/log4j-1.2.15.jar')
    compile files('libs/serializer-2.7.1.jar')
    compile files('libs/stringtemplate-3.2.1.jar')
    compile files('libs/txw2-20110809.jar')
    compile files('libs/w3c-css.jar')
//    compile 'com.android.support:support-annotations:22.2.0'
//    compile 'com.android.support:multidex:1.0.0'
}
Community
  • 1
  • 1
user1616685
  • 1,310
  • 1
  • 15
  • 36

1 Answers1

0

https://github.com/plutext/Docx4j4Android4/ is an Android Studio project; it uses Maven shade plugin to repackage org.apache.http

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84