Android Gradle Plugin 3.0.0: Multiple dex files define Lorg/xmlpull/mxp1/MXParser with XStream

后端 未结 1 1220
慢半拍i
慢半拍i 2020-12-21 05:48

Included projects that bring their own xmlpullparser always needed some extra care in Android Studio since Android brings its own xmlpullparser.

E.g. t

1条回答
  •  生来不讨喜
    2020-12-21 06:29

    Finally I found the fix. However, I am still puzzled why it depended on the Gradle Plugin Version.

    I am using logback-android that somehow depends on xpp3 as you can see on the dependency graph:

        +--- com.github.tony19:logback-android-classic:1.1.1-6
    |    |    +--- com.github.tony19:logback-android-core:1.1.1-6
    |    |    \--- com.github.tony19:apktool-lib:1.4.4-3
    |    |         \--- com.google.android:android:2.1_r1
    |    |              +--- commons-logging:commons-logging:1.1.1
    |    |              +--- org.apache.httpcomponents:httpclient:4.0.1
    |    |              |    +--- org.apache.httpcomponents:httpcore:4.0.1
    |    |              |    +--- commons-logging:commons-logging:1.1.1
    |    |              |    \--- commons-codec:commons-codec:1.3
    |    |              +--- org.khronos:opengl-api:gl1.1-android-2.1_r1
    |    |              +--- xerces:xmlParserAPIs:2.6.2
    |    |              \--- xpp3:xpp3:1.1.4c
    

    It must be said that I declared logback-android in a utils module which I then included into my app using implementation project(:'myUtilsModule')

    Now I excluded the group xpp3 with its module xpp3. The group and module names xmlpull wouldn't work.:

    // https://mvnrepository.com/artifact/com.github.tony19/logback-android-classic
    implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
        exclude group: 'xpp3', module: 'xpp3'  //in order to avoid "Multiple dex files define Lorg/xmlpull/v1/XmlPullParser;"
        //exclude group: 'xmlpull', module: 'xmlpull' //This works usually on other libs to exclude xmlpull, but not on that one
    }
    

    I learnt the hard way how to read the dependency graph and how to exclude items from the graph ;)

    1. Run How do I show dependencies tree in Android Studio?
    2. Each line in the dependency graph has the format ::
    3. which maps to the exclude arguments exclude group: '', module: '' or just exclude module: ''

    Update: With logback-android-1.1.1-7+ the exclude is no longer necessary.

    0 讨论(0)
提交回复
热议问题