https://bz.apache.org/bugzilla/show_bug.cgi?id=69288
Bug ID: 69288 Summary: SXSSFSheet constructor unnecessarily rethrows NoClassDefFoundError on Android Product: POI Version: unspecified Hardware: Other OS: other Status: NEW Severity: normal Priority: P2 Component: SXSSF Assignee: dev@poi.apache.org Reporter: samo.re...@gmail.com Target Milestone: --- In the SXSSFSheet constructor, there is this line: _autoSizeColumnTracker = new AutoSizeColumnTracker(this); On Android this throws NoClassDefFoundError: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/awt/font/FontRenderContext; at org.apache.poi.ss.util.SheetUtil.<clinit>(SheetUtil.java:98) at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117) at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:106) at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:694) at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:688) ... This is understandable, Android doesn't have AWT classes. There is a try/catch around this line, but the check inside is probably too strict: try { _autoSizeColumnTracker = new AutoSizeColumnTracker(this); } catch (UnsatisfiedLinkError | NoClassDefFoundError | InternalError | // thrown when no fonts are available in the workbook IndexOutOfBoundsException e) { // only handle special NoClassDefFound if (!e.getMessage().contains("X11FontManager")) { // close temporary resources when throwing exception in the constructor _writer.close(); throw e; } LOG.atWarn() .withThrowable(e) .log("Failed to create AutoSizeColumnTracker, possibly due to fonts not being installed in your OS"); } The exception is caught, but then rethrown. If the if condition was changed to: if (!e.getMessage().contains("X11FontManager") && !e.getMessage().contains("FontRenderContext")) { then we might be able to use the streaming APIs on Android. -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org