POI : duplicate entry: org/apache/xmlbeans/xml/str

2019-07-03 13:41发布

问题:

Android POI integration. I have done lots of search but did not find solution.

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

My gradle

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'

compile 'com.google.code.gson:gson:2.4'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.rey5137:material:1.2.2'
compile('com.github.afollestad.material-dialogs:core:0.8.5.4@aar') {
    transitive = true
}
compile('com.mikepenz:materialdrawer:5.0.0@aar') {
    transitive = true
}
compile 'com.pnikosis:materialish-progress:1.5'
compile 'org.apache.poi:poi-ooxml:3.13'

I found this https://github.com/sbt/sbt-proguard/issues/9

There is no solution here.

There is no solution here.

There is no solution here.

I did not used any other apache lib. and not used google play service. still the same issue is there.

回答1:

There a some discussions about how to get POI working on Android, see e.g. http://blog.kondratev.pro/2015/08/reading-xlsx-on-android-4-and-hopefully.html

The blow specifically states

[...] however it will not work straighforwardly because xmlbeans jar in maven is defective and contains duplicates of classes, [...] it is easier just to prepare jars once and put them into libs directory (as described above)

So you might need to do a few things to make it work or you can use the re-packaged project at https://github.com/andruhon/android5xlsx