plutext / Docx4j4Android4

Android Studio docx4j sample app
Apache License 2.0
29 stars 21 forks source link

java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/imageio/ImageIO; #7

Open hitesh-shukla opened 5 years ago

hitesh-shukla commented 5 years ago

Using BinaryPartAbstractImage getting error

Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.imageio.ImageIO"

hitesh-shukla commented 5 years ago

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/imageio/ImageIO; at org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO.getSupportedMIMETypes(ImageLoaderFactoryImageIO.java:39) at org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderFactoryImageIO.isAvailable(ImageLoaderFactoryImageIO.java:54) at org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry.registerLoaderFactory(ImageImplRegistry.java:182) at org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry.discoverClasspathImplementations(ImageImplRegistry.java:111) at org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry.(ImageImplRegistry.java:79) at org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry.(ImageImplRegistry.java:87) at org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry.(ImageImplRegistry.java:71) at org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry.getDefaultInstance(ImageImplRegistry.java:95) at org.apache.xmlgraphics.image.loader.ImageManager.(ImageManager.java:64) at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.getImageManager(BinaryPartAbstractImage.java:152) at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.getImageInfo(BinaryPartAbstractImage.java:905) at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.ensureFormatIsSupported(BinaryPartAbstractImage.java:521) at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.ensureFormatIsSupported(BinaryPartAbstractImage.java:500) at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.createImagePart(BinaryPartAbstractImage.java:264) at org.docx4j.openpackaging.parts.WordprocessingML.BinaryPartAbstractImage.createImagePart(BinaryPartAbstractImage.java:172)

jerryhero commented 5 years ago

same problem. Do you find the way to handle it?

hitesh-shukla commented 5 years ago

Not yet have tried to load template(docx file) from assets in API level below 23?

plutext commented 5 years ago

Regarding javax.imageio, this will take a bit of work to address. Basically the package needs to be added (with any binary deps removed), and xmlgraphics-commons using it (repackaged?).

See workaround: https://www.docx4java.org/forums/android-f19/add-image-t2190.html

And reports of success doing similar against previous/old approach: https://stackoverflow.com/questions/23327798/adding-image-with-docx4j-to-doc-file