Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DuplicateFileException: duplicate files copied in APK org/xerces/impl/msg/XMLSerializerMessage.properties #1

Open
naahac opened this issue Jun 2, 2017 · 6 comments

Comments

@naahac
Copy link

naahac commented Jun 2, 2017

I installed jena-android with local maven repository, as instructed on the main page of this project. I get this error when trying to deploy application:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org/apache/xerces/impl/msg/XMLSerializerMessages.properties
File1: C:\Users\Natanael.m2\repository\xerces\xercesImpl\2.11.0\xercesImpl-2.11.0.jar
File2: C:\Users\Natanael.m2\repository\mobi\seus\jena\xerces-android\2.11.0\xerces-android-2.11.0.jar

I tried to exclude the file but then I get another DuplicateFileException and after that another... (it seems to go on forever). I also suspect that the files are important and should not be excluded.

How can I resolve this?

@sbrunk
Copy link
Owner

sbrunk commented Jun 5, 2017

I haven't used it for quite some time, especially not with newer Android versions but I'll look into it as soon as possible.

@falegre05
Copy link

falegre05 commented Jul 4, 2017

I'm having exactly the same problem. I've tried to delete all and reinstall from the beginning but it didn't solved anything. I copy below the error message it appears to me when I try to execute your example hoping it helps you track the issue. It would be great that you could help us.

"_WARNING: Ignoring Android API artifact com.google.android:android:2.1_r1 for debug
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Ignoring Android API artifact com.google.android:android:2.1_r1 for debug
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for debug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Ignoring Android API artifact com.google.android:android:2.1_r1 for release
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Ignoring Android API artifact com.google.android:android:2.1_r1 for release
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.6 is ignored for release as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:extractProguardFiles
:app:preDebugBuild
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources
:app:generateDebugSources
:app:incrementalDebugJavaCompilationSafeguard
:app:javaPreCompileDebug
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED

FAILURE: Build failed with an exception.

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

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org/apache/xerces/impl/msg/XMLSerializerMessages.properties
File1: C:\Users\ferzi.m2\repository\mobi\seus\jena\xerces-android\2.11.0\xerces-android-2.11.0.jar
File2: C:\Users\ferzi.gradle\caches\modules-2\files-2.1\xerces\xercesImpl\2.11.0\9bb329db1cfc4e22462c9d6b43a8432f5850e92c\xercesImpl-2.11.0.jar

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output._"

@naahac
Copy link
Author

naahac commented Jul 4, 2017

I eventually just gave up and decided to implement Jena on simple REST service and then accessed the server from Android. I think that practically everything would have to be repackaged for every new Jena version... Extremely impractical...

I hope Jena includes official support for Android in the future...

@falegre05
Copy link

Oh, okay, thank you mate. I've decided not using it too and go for another technology.

I don't understand what they are waiting for to include it in Android but...

@samcn8
Copy link

samcn8 commented Aug 9, 2017

The following seems to work for me. In the module build.gradle file:

packagingOptions {
...
pickFirst 'org/apache/**'
pickFirst 'etc/**'
pickFirst 'jena-log4j.properties'
pickFirst 'ont-policy.rdf'
}

@daytrick
Copy link

Hello! Sorry to wake up a seven-year-old thread, but I recently ran into this issue and had to fix it.

@samcn8's solution worked for me too, but I also had to add some excludes rules to the Android Jena dependency in the app's build.gradle.kts. It looks like a lot, but there's only five of them - I found it helpful to comment in the exact errors being thrown so that I'd know the group and module names to exclude.

Tweaked code from @samcn8, in the app's build.gradle.kts:

android {
    ...
    packaging {
        resources.pickFirsts.add("org/apache/**")
        resources.pickFirsts.add("etc/**")
        resources.pickFirsts.add("jena-log4j.properties")
        resources.pickFirsts.add("ont-policy.rdf")
    }
}

Additional excludes rules, in the app's build.gradle.kts:

dependencies {
    ...

    implementation("mobi.seus.jena:jena-android-arq:2.13.0") {

        // Duplicate class com.hp.hpl.jena.Jena
        // found in modules jetified-jena-android-core-2.13.0 (mobi.seus.jena:jena-android-core:2.13.0)
        // and jetified-jena-core-2.13.0 (org.apache.jena:jena-core:2.13.0)
        exclude("org.apache.jena", "jena-core")

        // Duplicate class org.apache.jena.iri.IRI
        // found in modules jetified-jena-android-iri-1.1.2 (mobi.seus.jena:jena-android-iri:1.1.2)
        // and jetified-jena-iri-1.1.2 (org.apache.jena:jena-iri:1.1.2)
        exclude("org.apache.jena", "jena-iri")

        // Duplicate class org.apache.commons.logging.Log
        // found in modules jetified-commons-logging-1.1 (commons-logging:commons-logging:1.1.1)
        // and jetified-jcl-over-slf4j-1.7.6 (org.slf4j:jcl-over-slf4j:1.7.6)
        exclude("commons-logging", "commons-logging")

        // Duplicate class org.apache.html.dom.CollectionIndex
        // found in modules jetified-xerces-android-2.11.0 (mobi.seus.jena:xerces-android:2.11.0)
        // and jetified-xercesImpl-2.11.0 (xerces:xercesImpl:2.11.0)
        exclude("xerces", "xercesImpl")

        // Duplicate class org.w3c.dom.ElementTraversal
        // found in modules jetified-xerces-android-2.11.0 (mobi.seus.jena:xerces-android:2.11.0)
        // and jetified-xml-apis-1.4.01 (xml-apis:xml-apis:1.4.01)
        exclude("xml-apis", "xml-apis")

    }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants