Wednesday, July 22, 2015

Android Studio: Ill-advised or mistaken usage of a core class (java.* or javax.*)

Adding xmlrpc-client library to the application
                               compile 'org.apache.xmlrpc:xmlrpc-client:3.1.3'
causes the following error during run:
trouble processing "javax/xml/parsers/DocumentBuilder.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)


DocumentBuilder is already included in android. So we should exclude xml-apis in gradle:

compile ('org.apache.xmlrpc:xmlrpc-client:3.1.3') {
    exclude group: 'xml-apis'
}






But after that I’ve got the next errors:
Error:Execution failed for task ':app:packageDebug'.
> Duplicate files copied in APK META-INF/DEPENDENCIES
    File 1: C:\Users\jm\.gradle\caches\modules-2\files-2.1\org.apache.xmlrpc\xmlrpc-client\3.1.3\e486ad917028b52265610206fb5a1e2b5914b94b\xmlrpc-client-3.1.3.jar
    File 2: C:\Users\jm\.gradle\caches\modules-2\files-2.1\org.apache.xmlrpc\xmlrpc-common\3.1.3\415daf1f1473a947452588906dc9f5b3575fb44d\xmlrpc-common-3.1.3.jar
Information:BUILD FAILED
You can ignore those files in your build.gradle:
    android {
      packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
      }
    }

 
In this case there are at least two ways to fix:
1.       Use exclude in packagingOptions:
packagingOptions {
     exclude 'META-INF/DEPENDENCIES'
     exclude 'META-INF/LICENSE'
     exclude 'META-INF/NOTICE'
 }

2.       Use pickFirst option:
packagingOptions {
    pickFirst 'META-INF/DEPENDENCIES'
    pickFirst 'META-INF/LICENSE'
    pickFirst 'META-INF/NOTICE'
}


6 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.

    Data Science course in kalyan nagar | Data Science course in OMR
    Data Science course in chennai | Data science course in velachery
    Data science course in jaya nagar | Data science training in tambaram

    ReplyDelete
  3. I am sure this post has helped me save many hours of browsing other related posts just to find what I was looking for. Many thanks!
    python training in rajajinagar | Python training in btm | Python training in usa

    ReplyDelete
  4. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    java training in chennai | java training in bangalore


    java training in tambaram | java training in velachery

    ReplyDelete
  5. Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai

    ReplyDelete
  6. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 

    best rpa training in chennai | rpa online training |
    rpa training in chennai |
    rpa training in bangalore
    rpa training in pune

    ReplyDelete