Bug 63564 - StandardCharsets not supported before Android API 19
Summary: StandardCharsets not supported before Android API 19
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2019-07-12 13:04 UTC by Iaka Noe
Modified: 2019-07-12 16:06 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Iaka Noe 2019-07-12 13:04:16 UTC
I'm trying to use the POI library on Android API 17 but I can't since I get this exception:

java.lang.NoClassDefException: java.nio.charset.StandardCharsets
  at StringUtil.java:32

  protected static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;

Could this be changed to the following?

  protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");

It's backwards compatible and it's not deprecated for now... If not, an API check can also be done, but that would make the library only work for Android.
Comment 1 PJ Fanning 2019-07-12 15:20:07 UTC
POI is not supported on Android. For what I can see from issues on the POI mailing lists and on stackoverflow, users have not made much progress in getting it to work.

I'm not very familiar with Android versions.

https://en.wikipedia.org/wiki/Android_version_history#Android_4.2_Jelly_Bean_JOP40C_(API_17) was released in 2012 - but maybe you are referring to a newer version?
Comment 2 Iaka Noe 2019-07-12 15:29:44 UTC
POI works almost perfectly on the latest Android versions (couldn't get XSSF to work, but HSSF does, and flawlessly). But my client asked to make my project backwards compatible to Android 4.2 (API 17, indeed released on 2012). The thing is, the StandardCharsets class was added (probably ported from vanilla Java) later to API 19... There are many references to this class all over the code.

If I can't get this issue to be resolved, I'll probably get POI's source code and build it myself with the changes I need...
Comment 3 PJ Fanning 2019-07-12 16:04:14 UTC
Closing - as we don't intend latest POI versions to support really old Android releases.
Comment 4 PJ Fanning 2019-07-12 16:06:36 UTC
It might be worth trying POI 3.17 which supported older versions of Java.